Home > database >  how do i have to wrap codepush component on react-native
how do i have to wrap codepush component on react-native

Time:12-08

is it okay if I use codepush like this?

in my index.js

const RNRedux = () => (
  <Provider store={store}>
    <App />
  </Provider>
);

AppRegistry.registerComponent(appName, () => RNRedux);

I wrapped app component with redux provider

and in my App component has a lot of react-navigations.


App.js component looks like
  </NavigationContainer>

      <Stack.Screen

      />
      <Stack.Screen

      />
      <Stack.Screen

      />
      <Stack.Screen

      />
    </Stack.Navigator>
  </NavigationContainer>

export default CodePush(codePushOptions)(App);


I'm curious if I use codepush like this? I've heard that codepush has to be wrapped top of the components 

do I have to replace index.js and app.js ?




thanks for reading my question!

CodePudding user response:

you need to import in an index.js file, below is the updated code of your index.js file.

Index.js

 const RNRedux = () => (
      <Provider store={store}>
        <App />
       <CodePush />
      </Provider>
    );
    
    AppRegistry.registerComponent(appName, () => RNRedux);

App.js

  <Stack.Screen

  />
  <Stack.Screen

  />
  <Stack.Screen

  />
  <Stack.Screen

  />
</Stack.Navigator>
  • Related