React Global Events
SyntheticEvents from any React component to any others which are subscribed to that event.
npm install --save react-global-events
The most common implementation is to have a single root component listen for events.
// RootComponent.jsconst Root =<div id="app-root" ...>...<MySubComponent /></div>
Subcomponents may then subscribe to those events in
componentDidMount. They must then implement callback methods with the naming convention
onGlobal<ReactEventName>. Note that the
<ReactEventName> follows the camel-casing convetions of event names in React, not standard JS:
onGlobalMouseDown rather than
// MySubComponent.jsconst MySubComponent = React
You can have multiple components
listenFor events, but they can't choose which subscribers to broadcast to. The events are still broadcast globally.