I'm looking for a way in react-navigation to dispatch a navigation action and await for it to be fully finished before triggering the next step.
Something like:
await dispatch({
type: 'Navigation/goBackTo',
routeName: 'Main',
})
dispatch(anotherAction())
Currently I'm using a setTimeout workaround.
animationEnabled If you set it to false , the screen won't animate when pushing or popping. Defaults to true on iOS and Android, false on Web.
Provides a way for your app to transition between screens where each new screen is placed on top of a stack. By default the stack navigator is configured to have the familiar iOS and Android look & feel: new screens slide in from the right on iOS, fade in from the bottom on Android.
TL;DR: React Navigation has a declarative API with built-in hooks, while React Native Navigation has imperative APIs with a community library for Hooks. React has changed how we think about interface development.
Not specifically related to react-navigation, but useful nonetheless: the InteractionManager API from react-native.
There is a method runAfterInteractions() which will be called after all animations have been completed, so in case of navigation I find it to be a handy tool. For example you could do something like this:
class Main extends Component {
componentDidMount() {
// 1: Component has been mounted off-screen
InteractionManager.runAfterInteractions(() => {
// 2: Component is done animating
// 3: Do your anotherAction dispatch() here
});
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With