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 state on new props #1300

Closed
wants to merge 1 commit into from
Closed

Conversation

pwmckenna
Copy link
Contributor

So, this isn't really the perfect pull request to do this, but what I'm trying to accomplish is making the Navigator more declarative. If I change the initialRouteStack (might need to introduce a new routes prop so that the naming isn't confusing), it would be nice if the navigator rerendered with the new stack. Obviously blowing away the existing stack wouldn't be ideal in all cases, but I can't think of a better way to blow away the existing navigator and replace it with a new one with the updated stack of routes.

Alternatively, it might be nice to have resetTo accept an array of routes.

@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 15, 2015
@ericvicenti
Copy link
Contributor

I agree that it would be ideal if Navigator were more declarative. But I am pretty sure this would be problematic with the current system because any re-rendering outside of the navigator will cause the routes to be blown away by the initial routes.

An example: If I create a navigator with scene A, and then scene A causes scene B to be pushed, any re-render of the navigator would cause scene B to disappear!

I'm happy to discuss this more, but I think this approach will be problematic without making some deeper changes.

@pwmckenna
Copy link
Contributor Author

fair enough. thoughts on resetTo accepting an array of routes? perhaps a seperate name? I'd be happy to make a pull request.

@ericvicenti
Copy link
Contributor

Sorry for the delayed response here.

We have immediatelyResetRouteStack, which accepts an array, but it will not use an animation. If you need a form of resetTo that animates back and also accepts an array of routes, then you could submit a PR for that. The names for these actions are a bit confusing, so feedback is welcome on that as well.

@pwmckenna
Copy link
Contributor Author

ah! immediatelyResetRouteStack is perfect for my use case. thanks!

@pwmckenna pwmckenna closed this May 19, 2015
@ericvicenti
Copy link
Contributor

Great! Let me know if you have an idea for a better name/naming convention.

We might want to have two sets of nav actions with consistent names. They would have the same effect on the stack, but one set of actions would happen instantly and the other set animates.

ayushjainrksh pushed a commit to MLH-Fellowship/react-native that referenced this pull request Jul 2, 2020
This change adds a section for debugging application state (Redux and MobX-State-Tree, the two most popular state management systems in React Native) using Reactotron. See discussion in Discord #website for more info.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants