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

New redux warning? #137

Open
jalada opened this issue Apr 16, 2018 · 5 comments
Open

New redux warning? #137

jalada opened this issue Apr 16, 2018 · 5 comments

Comments

@jalada
Copy link

jalada commented Apr 16, 2018

Hello!

We used react-navigation on a project a while ago, and integrated it with our Redux store as per the documentation. But I've just noticed you now have a warning telling people not to do this.

  1. Can you elaborate why it's bad? "You probably don't need to do this" is a bit ambiguous.
  2. Managing navigation through actions was our main reason for doing it; it meant one LOGIN_SUCCEEDED action would mutate both our app state and the navigation state to put the user in the right place. What's the recommended approach instead? Is it to navigate without the navigation prop?
@brentvatne
Copy link
Member

hi @jalada! we have an issue here to discuss in depth: react-navigation/rfcs#14

I wouldn't say it's bad necessarily, like I wrote in the warning "Storing your React Navigation state in your own Redux store is likely to give you a very difficult time if you don't know what you're doing." -- you can search the issues on the main react navigation repo and see how many are related to not integrating properly with Redux. Additionally, it's a lot more difficult for us to provide support for users who integrate their state into Redux because the environment is more complex and issues are harder to reproduce in an isolated way.

Managing navigation through actions was our main reason for doing it; it meant one LOGIN_SUCCEEDED action would mutate both our app state and the navigation state to put the user in the right place. What's the recommended approach instead? Is it to navigate without the navigation prop?

That's one way you could grab the dispatch function, yeah. If you'd like to perform navigation actions in some Redux middleware then this would be a good approach.

@askpatrickw
Copy link

The docs as-is make it sound like you can't user Redux with react-navigation at all. But in issues I'm reading that is only related to using redux to store navigation state. Might be worth adding an explicit comment to the docs on that.

@AshtonKem
Copy link

I personally agree with the warning about using redux, personally I find the mixing of navigation & application state to be ... weird.

That being said, I think it would be a great idea to give a recommended alternative. A lot of us want to navigate to a separate route after a reducer finishes, but it's not clear what the recommended way to accomplish that is.

@brentvatne
Copy link
Member

@w7pea - could you send a PR to clarify that in the docs? thanks!

@askpatrickw
Copy link

@brentvatne, my grasp of redux is pretty low (I'm really a python dev) so I'm not sure how good my comments would be, but I'll provide this and let you all have a whack edit. I do stand by comment though and initially I thought I couldn't use react-navigation and redux at all in the same application (in my case react-native). Hope this helps.

Current

Warning: in the next major version of React Navigation, to be released in Fall 2018, we will no longer provide any information about how to integrate with Redux and it may cease to work. Issues related to Redux that are posted on the React Navigation issue tracker will be immediately closed. Redux integration may continue to work but it will not be tested against or considered when making any design decisions for the library.

Edited

Warning: in the next major version of React Navigation, to be released in Fall 2018, we will no longer provide any information about how to integrate with Redux to drive nvigation and it may cease to work. Issues related to Redux that are posted on the React Navigation issue tracker will be immediately closed. Redux integration to drive navigation may continue to work but it will not be tested against or considered when making any design decisions for the library.

NOTE: This only pertains to using Redux to drive navigation. It does impact the ability to use Redux for its other common use cases.

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

No branches or pull requests

4 participants