Created
November 5, 2018 14:34
-
-
Save chentsulin/9917890eda384589c87dfa8e8b34f8c6 to your computer and use it in GitHub Desktop.
Lifecycle
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 App extends Component { | |
componentDidMount() { | |
this.subscribe(this.props.userId); | |
} | |
componentDidUpdate(prevProps) { | |
if (this.props.userId !== prevProps.userId) { | |
this.unsubscribe(this.props.userId); | |
this.subscribe(this.props.userId); | |
} | |
} | |
componentWillUnmount() { | |
this.unsubscribe(this.props.userId); | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment