Search code examples
react-nativevisual-studio-app-centercode-push

adding code push to react native appcenter app


My react native app is working ok, but now need to add code push,

my question is where to add the

CodePush

On the "App"

Here my code,

const App = () => (
  
  <Provider store={store}>
    <NavigationContainer>
      <SafeAreaProvider>
        <View style={styles.container}>
          <Main/>
        </View>
      </SafeAreaProvider>
    </NavigationContainer>
  </Provider>
);

// let codePushOptions = { checkFrequency: CodePush.CheckFrequency.ON_APP_START };

// App = CodePush(codePushOptions)(App);

export default App;

But if I uncomment

let codePushOptions = { checkFrequency: CodePush.CheckFrequency.ON_APP_START };

App = CodePush(codePushOptions)(App);

export default App;

is Crashing...

How to properly add the CodePush to my App?


Solution

  • You dont have to set the value to the App, you can directly return like below

    let codePushOptions = { checkFrequency: CodePush.CheckFrequency.ON_APP_START };
    
    export default CodePush(codePushOptions)(App);