Navigation outside the React lifecycle should be provided rather than docs with DIY solutions #10194
Replies: 1 comment 6 replies
-
I don't really see what business logic needs to be created by users - you call
That's not what's suggested, it's mentioned as one of the options because you could do this based on your requirements. I don't have such queue maintained in any app I have worked on and haven't needed it. I believe most apps don't need queue for navigation actions. A queue makes sense for any event listeners you add, and that's something handled by
I don't disagree, but if your application code is trying to navigate before your app is mounted, then it's something you need to investigate and fix in your app logic. React Navigation could try to make it easier to debug such things if there's anything that could be done here. The library can't decide what to do when you're navigating even before anything is mounted, because we don't know what your use case is and what makes sense for your needs. Most apps wouldn't need a queue and queuing can cause bugs if the data has changed since the action was queued. The ref approach is really an escape hatch that shouldn't be used often anyway (navigations should primarily happen due to user interaction), and queue is an even more special case.
I don't think there's any general solution for this, but feel free to suggest ideas. Maybe the documentation can be improved to make it more clear.
You should first create a proposal about what's going to be in a PR. |
Beta Was this translation helpful? Give feedback.
-
Current behavior
The React Navigation docs suggest creating a tiny abstraction layer for working with navigation from outside the React lifecycle. In v6
createNavigationContainerRef
was provided which was a step in the right direction. I am suggesting to bring this whole code into React Navigation. Consider the following:Would the authors of React Navigation consider adding a PR with this functionality or would they consider PRs from contributors?
Expected behavior
Provide navigation outside the React lifecycle without suggesting DIY implementations to end users
Reproduction
https://reactnavigation.org/docs/navigating-without-navigation-prop/
Platform
Packages
Environment
v6 latest
Beta Was this translation helpful? Give feedback.
All reactions