react-eventsource

Connect your react components to any EventSource

MIT License

Downloads
29
Stars
25

react-eventsource

Connect your react components to any EventSource

Usage

import ReactEventSource from 'react-eventsource'

const renderEvent = event => <div>{ event }</div>

<ReactEventSource url="https://stream.wikimedia.org/v2/stream/recentchange">
    { events => events.map(renderEvent) }
</ReactEventSource>

By default, ReactEventSource will listen to message events.

If you use custom message types, you can specify them using types={['data', 'patch']}

You can pass your own EventSource using source prop source={new EventSource(url)},

See working demo with Live Bitcoin value update : http://revolunet.github.io/react-eventsource/#/demo

Dev

This project use nwb

License

react-eventsource is available under MIT. See LICENSE for more details.