I have a page A, then navigate to page B, then go back. I want to know which life cycle method will be called on A, or event will be emitted?
When using react-navigation, you can subscribe to the didFocus and didBlur events to be notified when the user navigates to or from a screen.
You can set these up in your component's componentDidMount using the addListener method of this.props.navigation like this:
componentDidMount() {
this.props.navigation.addListener("didFocus", () => {
// user has navigated to this screen
});
this.props.navigation.addListener("didBlur", () => {
// user has navigated away from this screen
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With