-
-
Save abdyer/8b29026440b1f6c06e3d2f7bc149fbe8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BeerList extends React.Component { | |
componentDidMount() { | |
this.changeListener = | |
DeviceEventEmitter.addListener( | |
'beersChanged', | |
this.onBeersChanged); | |
NativeModules.BeerLiveData.subscribe(); | |
} | |
componentWillUnmount() { | |
this.changeListener.remove(); | |
NativeModules.BeerLiveData.unsubscribe(); | |
} | |
beersChanged = (event) => { | |
const beers = JSON.parse(event.beers); | |
this.setState({beers: beers}); | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment