Skip to content

Instantly share code, notes, and snippets.

@viclotana
Created October 25, 2018 16:11
Show Gist options
  • Save viclotana/3ec7fd1e7f3d54a3f2b0eb64e735c46a to your computer and use it in GitHub Desktop.
Save viclotana/3ec7fd1e7f3d54a3f2b0eb64e735c46a to your computer and use it in GitHub Desktop.
class MyClass extends React.Component {
static contextType = MyContext;
componentDidMount() {
let value = this.context;
/* perform a side-effect at mount using the value of MyContext */
}
componentDidUpdate() {
let value = this.context;
/* ... */
}
componentWillUnmount() {
let value = this.context;
/* ... */
}
render() {
let value = this.context;
/* render something based on the value of MyContext */
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment