Skip to content

Instantly share code, notes, and snippets.

@atuttle
Created April 9, 2016 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atuttle/ae89e9e5cf8163d66c6e94f1fa8a389b to your computer and use it in GitHub Desktop.
Save atuttle/ae89e9e5cf8163d66c6e94f1fa8a389b to your computer and use it in GitHub Desktop.
var store = require('store') //my redux store
var unsubscribe
var MyComponent = React.createClass({
componentDidMount: function componentDidMount(){
unsubscribe = store.subscribe(function handleStateChange(){
// in ES6 we could do this: this.forceUpdate()
// but what is the solution for ES<6?
})
}
,componentWillUnmount: function componentWillUnmount() {
unsubscribe()
}
,render: function render() {
var state = store.getState()
//...
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment