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

Multiple routers with v4? #2274

Closed
JaxGit opened this issue Aug 22, 2017 · 2 comments
Closed

Multiple routers with v4? #2274

JaxGit opened this issue Aug 22, 2017 · 2 comments

Comments

@JaxGit
Copy link

JaxGit commented Aug 22, 2017

Our navigation is so complex that we are planning to use a router for main navigations and another for navigations in side drawer. (just like #353 and many others but with v4)
We are currently using react-native-drawer instead of react-navigation drawer as described in this comment because the former works well with react-native-scrollable-tabview.

We could demonstrate multiple 'routers' with pure react-navigation when connecting multiple AppNavigator to redux, however when using multiple <Router/> of router-flux v4 it failed with error "no route defined for key [other router scene key]" in getScreenForRouteName.

As it seems in router-flux the AppNavigator is a new navigator created by new NavigationStore instance create(), I guess this is still possible to achieve with appropriate extensions?

@aksonov
Copy link
Owner

aksonov commented Aug 22, 2017

Current Actions (navigationStore) is singleton for simplicity - i.e. one instance across ap.. It is not difficult to support multiple navigationStore instances by exporting also NavigationStore class from navigationStore.js and don't use Actions but app-defined classes for it. After that it is easy to modify Router.js to accept navigationStore as optional parameter or create new instance of NavigationStore class each time.

PR is welcome. I don't have time to implement it right now and I would need some demo code anyway to work with.

@JaxGit
Copy link
Author

JaxGit commented Aug 23, 2017

Thanks for your explanation~
We are currently time restricted and may not have time for extension either, also our case may be a bit rare and single Router with react-navigation built-in drawer is sufficient for most of the cases. However we verified the following workaround for us which is faster:

  • Upgrade to router-flux v4, keep using it for main navigations and track main nav states in redux by createReducer prop;
  • Use pure react-navigation Navigator and manage drawer nav states in redux.

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

2 participants