I'm in a situation that user needs to navigate for a moment to group of other screens to add some data and then go back to the first screen. The first screen has data that was passed to it through navigate params. I need this data to remain after changing screens. This works when user in order to get back there is using couple times
navigation.goBack()
but when I try to go back to specific screen using
navigation.navigate({key: 'edit'})
then it pops
Render error
undefined is not an object (evaluating '_route$params.payment')
CodePudding user response:
Use popToTop or pop to go back multiple screens.
import { StackActions } from '@react-navigation/native';
navigation.dispatch(StackActions.popToTop());
// or
navigation.dispatch(StackActions.pop(2));