I'm on screen A which has current state of {key:'value'} , I navigated to screen B
now I'm trying to pop from screen B to screen A again , but I don't want to lose the current state in screen A {key:'value'}
some solution is to save data in the AsynStorage , and retrive it when coming back to screen A , but that's not a good practice
.pop() do it , but what if I need to go back with additional params ?
Navigation.pop(this.props.componentId , {
passProps: {
data : 'current',
more : 'just-example'
}});
the above code , did not work
any suggestions ?
I don't use any state management tool like Redux/Mobx ..
I found a good solution is to send a callback function with the params
in screen A
getback(success)
{
alert(success);
}
Navigation.push(this.props.componentId , { component : {
name : "Payment",
passProps: {
subscription : current,
getback: this.getback
},
}});
then in screen B , when you pop to screen A fire the getback function
Navigation.pop(this.props.componentId);
this.props.getback(true);
this worked well with me
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