Last active
May 19, 2016 18:18
-
-
Save goldhand/faca3d0804b68ca459ad24bfd6cfee14 to your computer and use it in GitHub Desktop.
The long version of what connect react-redux method replacing
This file contains hidden or 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 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