ReactFix
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • React
  • React Native
  • Programming
  • Object Oriented Programming

Monday, December 12, 2022

[FIXED] how do i have to wrap codepush component on react-native

 December 12, 2022     code-push, react-native, react-native-code-push, reactjs   

Issue

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!

Solution

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>


Answered By - Ankit Vora
Answer Checked By - - David Goodson (ReactFix Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Newer Post Older Post Home

Featured Post

Is Learning React Difficult?

React is difficult to learn, no ifs and buts. React isn't inherently difficult to learn. It's a framework that's different from ...

Total Pageviews

Copyright © ReactFix