Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React native Stack navigation how to use 'replace' in Stack action

I want to use the replace method in Stack Actions in react navigation v2, but I'm not quite sure how I've looked at the specification here, https://reactnavigation.org/docs/en/stack-actions.html but I can't get it to work.

import { StackActions, NavigationActions } from 'react-navigation';

const resetAction = StackActions.reset({

key:,
newKey:
routeName:

});
this.props.navigation.dispatch(resetAction);

I guess it's gotta be in some above format, but i'm not sure what has to go in to the parameters. Can anyone give me a working example?

like image 284
Eric Ahn Avatar asked Oct 26 '25 21:10

Eric Ahn


1 Answers

Are you trying to reset or to replace?

  • Use "Reset" when you want to erase all stack and create a new one. for example when deep linking to a certain path.
  • Use "Replace" when you want to replace a specific element in the stack. for example you want to this.props.navigation.goBack() and navigate to a different route than where you came from
like image 77
YaNuSH Avatar answered Oct 29 '25 19:10

YaNuSH



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!