mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-22 11:52:00 +00:00
Added side effects props change example
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user