I'm having trouble with resetting the navigation params to null in React Native.
MainTab
-- Home (stack)
-- Misc (stack)
-- Tips (stack)
On the Home tab, I have a button to go to Misc, but I want to route to the Tips tab on route to Misc.
Routing should look like - (Home -> Tips -> Misc)
That button returns the following with params -
this.props.navigation.navigate('Tips', {backRoute: 'Home', routeImGoingNext: 'Misc'});
When these params are passed, I render a back button and a skip button on the Tips screen's navigation based on the backRoute and routeImGoingNext params that were passed from the button on the Home tab.
if(navigation.state.params && navigation.state.params.backRoute){
return {
headerLeft: (<HeaderBackButton onPress={()=>navigation.navigate(navigation.state.params.backRoute)}/> ),
headerRight: (
<TouchableOpacity onPress={()=>navigation.navigate(navigation.state.params.routeImGoingnext)}>
<Text style={{paddingRight: 10}}> Skip </Text>
</TouchableOpacity>
)
}
}
My problem occurs when I click the Tips tab after I've already clicked the the button on the Home tab. The params are still set and therefore rendering a back button and skip button, but there shouldn't be those buttons if I click the Tips tab.
Any ideas on how to reset the params when you manually click on the tabs?
