Couldn't find it in the docs: What is the best practice when using React Navigation together with Redux?
Should you do 1.:
export default withNavigation(connect(
mapStateToProps,
{ someFunction }
)(SomeComponent))
Or 2.:
export default connect(
mapStateToProps,
{ someFunction }
)(withNavigation(SomeComponent))
?
To handle your app's navigation state in Redux, you can pass your own navigation prop to a navigator. Once you pass your own navigation prop to the navigator, the default navigation prop gets destroyed. You must construct your own navigation prop with state , dispatch , and addListener properties.
This can happen if you are passing non-serializable values such as class instances, functions etc. in params. React Navigation warns you in this case because this can break other functionality such state persistence, deep linking etc.
After some googling it seems to be that 1. is the best practice.
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