pass onTransitionStart's return value back to caller#27
pass onTransitionStart's return value back to caller#27mramad2 wants to merge 1 commit intoreact-navigation:masterfrom
Conversation
|
The implemention of stack is going to change very soon. I'd not recommend relying on these props. Also this feels like the wrong place to put async logic. Why not do the async call first before triggering the navigation? |
|
We want to use the opportunity before navigating to a screen to fetch down some additional content to store offline and use on the screen. The react navigation gets invoked in such a way that we have no means of examining where the route leads to before the transition starts. The scenario we hope to accomplish is somewhat more complex than how I explained it, but looking at onTransitionStart, I was under the impression that it would wait on async actions to complete. |
I don't know the original intention behind the await. But I doubt that it waits for the new screen to mount after
It sounds like the way your code is structured, and it should be possible to restructure it to achieve what you want. I feel the most maintainable way is to make a screen fetch it's own data rather than fetching it before navigating, and waiting for unknown amount of time (network can be slow) before navigating isn't a great UX either. Anyway, I'm closing this because transitioner is going away and whatever this will enable will break very soon. |
Use case: If we want to wait for an async call to complete before proceeding with the navigation
Transitioner checks to see if value is promise, and if so it waits.
https://github.com/react-navigation/stack/blob/676bc3b45a7715edecd13530ae3b39ee1fe48833/src/views/Transitioner.tsx#L204