ActionCable for react native.
Just import actioncable
module, and let it compatiblely with react native
.
Install
npm install --save react-native-actioncable
Usage
Two ways to use react-native-actioncable
Use ActionCable methods
import ActionCable from 'react-native-actioncable' const cable = ActionCable // ... Other code
react-actioncable-provider
Use with In outer container:
import ActionCable from 'react-native-actioncable'import ActionCableProvider from 'react-actioncable-provider' const cable = ActionCable { return <ActionCableProvider => <MyApp /> </ActionCableProvider> }
In some UI screen:
import React Component PropTypes from 'react' static contextTypes = cable: PropTypesobjectisRequired ; { thissubscription = thiscontextcablesubscriptions } { thissubscription && thiscontextcablesubscriptions } // ... Other code