Created
July 1, 2020 13:09
-
-
Save mrcthms/b7a83eb33516a0b45c781de1acda0c22 to your computer and use it in GitHub Desktop.
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 MyComponent extends Component { | |
componentDidMount() { | |
this.doSideEffect(this.props.foo) | |
} | |
componentDidUpdate(prev) { | |
if (prev.foo !== this.props.foo) { | |
this.doSideEffect(this.props.foo) | |
} | |
} | |
doSideEffect = (foo) => { | |
console.log(foo) | |
} | |
render() { | |
return <div>Hello, world</div> | |
} | |
} | |
<MyComponent foo={WHATEVER} /> |
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 MyComponent extends Component { | |
componentDidMount() { | |
this.doSideEffect(this.props.foo) | |
} | |
doSideEffect = (foo) => { | |
console.log(foo) | |
} | |
render() { | |
return <div>Hello, world</div> | |
} | |
} | |
<MyComponent foo={WHATEVER} /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment