Added side effects props change example

This commit is contained in:
Brian Vaughn
2018-03-28 10:27:36 -07:00
parent 95f2a184d0
commit 6afbc7b56e
3 changed files with 31 additions and 2 deletions

View File

@@ -0,0 +1,9 @@
// After
class ExampleComponent extends React.Component {
// highlight-range{1-5}
componentDidUpdate(prevProps, prevState) {
if (this.props.isVisible !== prevProps.isVisible) {
logVisibleChange(this.props.isVisible);
}
}
}

View File

@@ -0,0 +1,9 @@
// Before
class ExampleComponent extends React.Component {
// highlight-range{1-5}
componentWillReceiveProps(nextProps) {
if (this.props.isVisible !== nextProps.isVisible) {
logVisibleChange(nextProps.isVisible);
}
}
}