React-native-router-flux: Reset stack with transition

Created on 14 Aug 2017  路  12Comments  路  Source: aksonov/react-native-router-flux

I'm trying to reset the stack when transitioning a scene. Is this possible?
I know that{ type: "reset" } and { type: "replace" } works, but without transition.

Thanks


Edit

I've seen that react-navigation has some method for this:

const resetAction = NavigationActions.reset({
  index: 0,
  actions: [
    NavigationActions.navigate({ routeName: 'Profile'})
  ]
})
this.props.navigation.dispatch(resetAction)

How can I achieve this on RNRF?

needs response from author

Most helpful comment

@aksonov any news on this? I want to reset stack to new screen with transition is this possible with transitionConfig?

All 12 comments

@aksonov Tips?

Try to modify RNRF's navigationStore.reset to your one and check.

Where can I get navigationStore.reset? I didn't find it in props.

@aksonov suggestions?

I meant fork & edit source code of RNRF (and rebuild dist folder)

But since React Navigation has this option, shouldn't RNRF has this as well?

I can add it but I need clear demo first to understand issue. Please fork & modify Example project.

I'm getting an error when trying to fork & run:
ENOENT: no such file or directory, uv_chdir

Still, I think it's pretty simple what I'm suggesting.

[Screen 1] -> [Screen 2] -> [Screen 1]

Here, we are transitioning through screens. However, what I'm suggesting is when user reaches the last screen 1, RNRF resets the stack, not allowing the user to go back by NavBar or swipe.

'replace' does this trick, right? Do you want also animation? It seems out of scope for this component (and a bit unusual) - why just don't use Actions.pop ? I've tried also method you mentioned (react-navigation one) and I don't see any animation for it as well.

@aksonov any news on this? I want to reset stack to new screen with transition is this possible with transitionConfig?

@shukerullah Since RNRF is based on React Navigation, this is not possible yet.
However there are some discussions on React Navigation repo based on this issue:

react-community/react-navigation/issues/2390
react-community/react-navigation/issues/1493

What I was suggested to @aksonov is something similar as Facebook does on Navigator with resetTo:
http://facebook.github.io/react-native/releases/0.34/docs/navigator.html#resetto

resetTo(route)
Navigate to a new scene and reset route stack.

From what I've learned, it appears that react-navigation will approach this on V 1.0. I don't know if is possible to apply this on RNRF, but I think this is a must both on RNRF or react-navigation.

@aksonov Since we now can reset a child stack, would it be possible?
Something like resetTo from https://github.com/wix/react-native-navigation/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wootwoot1234 picture wootwoot1234  路  3Comments

moaxaca picture moaxaca  路  3Comments

jgibbons picture jgibbons  路  3Comments

GCour picture GCour  路  3Comments

xnog picture xnog  路  3Comments