Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset stack with transition #2236

Closed
luco opened this issue Aug 14, 2017 · 12 comments
Closed

Reset stack with transition #2236

luco opened this issue Aug 14, 2017 · 12 comments

Comments

@luco
Copy link
Contributor

luco commented Aug 14, 2017

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?

@luco
Copy link
Contributor Author

luco commented Aug 15, 2017

@aksonov Tips?

@aksonov
Copy link
Owner

aksonov commented Aug 15, 2017

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

@luco
Copy link
Contributor Author

luco commented Aug 16, 2017

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

@luco
Copy link
Contributor Author

luco commented Aug 17, 2017

@aksonov suggestions?

@aksonov
Copy link
Owner

aksonov commented Aug 18, 2017

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

@luco
Copy link
Contributor Author

luco commented Aug 21, 2017

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

@aksonov
Copy link
Owner

aksonov commented Aug 23, 2017

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

@luco
Copy link
Contributor Author

luco commented Aug 23, 2017

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.

@aksonov
Copy link
Owner

aksonov commented Aug 23, 2017

'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 aksonov closed this as completed Aug 23, 2017
@shukerullah
Copy link

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

@luco
Copy link
Contributor Author

luco commented Sep 24, 2017

@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-navigation/react-navigation/issues/2390
react-navigation/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.

@luco
Copy link
Contributor Author

luco commented Dec 25, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants