Whats the best way to refresh the previous page when going back using Stack Navigator. No life cycle hooks seems to be triggered on the page i am returning to. I'm just using the basic example and this.props.navigation.goBack()
You can go back to an existing screen in the stack with navigation. navigate('RouteName') , and you can go back to the first screen in the stack with navigation.
To make this work, you need to: Disable the swipe gesture for the screen ( gestureEnabled: false ). Override the native back button in the header with a custom back button ( headerLeft: (props) => <CustomBackButton {... props} /> ).
You can use addListener
for this
componentDidMount() {
this.props.navigation.addListener(
'didFocus',
payload => {
this.forceUpdate();
}
);
}
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