4

There are a couple of tutorials online on how to use react-native-navigation with Redux. However, none of them is complete and I really do not understand what do I need to return in my root function.

If I do return

<Provider store={mystore}>
<MainScreen />
</Provider>

Then, why the need to use registerComponentWithRedux? If I use registerComponentWithRedux then I would expect to not to have to wrap my component with the provider again.

Can anyone clarify this, or does any one know a full-complete-working example of react-native-navigation with registerComponentWithRedux?

As said, I saw plenty of tutorials online but they do not specify what is returned in the entry file of the application.

Jose
  • 1,389
  • 3
  • 16
  • 25

2 Answers2

2

registerComponentWithRedux() has been deprecated in favor of Registering screens with wrapping provider component.

The code sample you provide is actually the correct way to do it since the registerComponentWithRedux function has been deprecated. Registering a screen with redux would look something like this (sample from RNN docs):

Navigation.registerComponent('navigation.playground.ReduxScreen', () => (props) => (
  <Provider store={reduxStore}>
    <ReduxScreen {...props} />
  </Provider>
), () => ReduxScreen);
1

As the docs of React Native Navigation -Version2 describes, registering component with Redux goes as below:

Navigation.registerComponent('WelcomeComponentScreen', () => (props) => (
  <Provider store={reduxStore}>
    <'WelcomeComponentScreen' {...props} />
  </Provider>
), () => 'WelcomeComponentScreen');
xMan
  • 11
  • 2