rc-listener
v1.0.0
Published
An event-listener wrapped in a react component
Downloads
2
Maintainers
Readme
rc-listener
An event-listener wrapped in a react component
Install
npm install --save rc-listener
Usage
import React, { Component } from 'react'
import { Listener } from 'rc-listener'
function App() {
return (
<Listener
event="message"
identifier={event => event.details.id === 'heartBeat'}
>
{
(event) =>
<UserAgent event={event} />
}
</Listener>
);
}
function UserAgent(props) {
return (
<div>
{props.event ? (
<div>Your ping: {props.event.details.ping}</div>
) : (
"Loading ..."
)}
</div>
);
}
License
MIT © BnayaZil