navigation-rfc
navigation-rfc copied to clipboard
What would be the right way for scene know it's in focus?
My use case is that a scene A needs to know it's in focus when the user navigates back from scene B. I would like to decouple the back button from Scene B action from my scene A. Which means I'm looking for a way that animatedView to notifiy that Scene B is back in focus.
Hope it makes sense! Thanks your work btw :)
In componentWillUpdate or componentDidUpdate of the view containing the NavigationAnimatedView, you can detect the case that you are going back from B to A. Then you can adjust the state so that scene A can see the change
@jnak: Please keep in mind that that NavigationAnimatedView
is deprecated.
For focus change, there are to ways to detect focus change.
- The navigation states is owned and managed by you, so you should be able to detect the focused index changes via your data flow process.
- Alternatively, you could rely on the component to tell you what the focus may change.
<NavigationTransitioner
onTranstionEnd={(currentScenes, prevScenes) => {
// compute the focus change here.
}}
/>
Thanks guys for the answers. The onTranstionEnd callback makes the most sense to me. Any interest to add this as a built-in props passed to scenes?