Skip to content

Instantly share code, notes, and snippets.

@goldhand
Last active May 19, 2016 18:18
Show Gist options
  • Save goldhand/faca3d0804b68ca459ad24bfd6cfee14 to your computer and use it in GitHub Desktop.
Save goldhand/faca3d0804b68ca459ad24bfd6cfee14 to your computer and use it in GitHub Desktop.
The long version of what connect react-redux method replacing
class ContextComponent extend React.Componet {
static contextTypes = {
store: PropTypes.object,
}
componentDidMount() {
this.unsubscribe = this.context.store.subscribe(() => {
this.forceUpdate();
});
}
componentWillUnmount() {
this.unsubscribe();
}
render() {
const {store} = this.context,
state = store.getState();
}
}
/*
* <Provider store={createStore()}>
* <ContextComponent />
* </Provider>
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment