I'm using NavigatorIOS on my react native app. I want to pass some properties when navigating back to previous route.
An example case: I'm in a form page. After submitting data, I want to go back to the previous route and do something based on the submitted data
How can I pass the state variables of my current element to the previous route when using pop to go back?
Any code sample would be greatly appreciated.
This is a classic example of what is trivially solved with Redux or some other centralized state store.
Without that, is the behavior that you go "back" via NavigatorIOS's pop
method? It takes no arguments, so I doubt that'll work at all.
The best you could do is only use push
, where you can define the route
which could contain the form data in passProps
:
this.props.navigator.push({
title: NavigatorIOSExample.title,
component: NavigatorIOSExamplePage,
backButtonTitle: 'Custom Back',
passProps: { formData },
});
But really, use Redux.