Differences between this.props.navigation.dispatch and this.props.navigation.navigate?

I see a lot of people in the response problems section using this.props.navigation.dispatch for programmatic navigation. Is there any specific reason or use case for using this.props.navigation.navigate ?

It seems that you can pass additional parameters to the send function? Is there anything else? Can you use dispatching without explicitly linking reaction-navigation to your apps apps store? Right now I have an application that has reduction, but I don’t want to explicitly configure my reduction settings to know about interactive navigation (and would rather save it that way if I can).

+5
source share
2 answers

From React Navigation docs. Navigation Prop section ( https://reactnavigation.org/docs/navigators/navigation-prop#dispatch-Send-an-action-to-the-router ):

... Other navigation features use sending behind the scenes ...

Also, the parameters for NavigationActions.navigate and this.props.navigation.navigate same. There should be no difference which one you use. In my opinion, this.props.navigation.navigate shorter and more readable.

+3
source

From github πŸ‘‡πŸ»:

enter image description here

This is the navigate function code that reuses navigation.dispatch .. And remember:

Do Not Lie Code

Then navigation.navigate(...args) is an alias of navigation.dispatch(NavigationActions.navigate(...args))

+1
source

All Articles