[Solved] requireNativeComponent: "RNSScreenStackHeaderConfig" was not found in the UIManager when running android app

React JS Sharif Ahmed

Problem:

I was working on a react native project. When running an application on android I get this error. It builds correctly but crashes with exception.

requireNativeComponent: "RNSScreenStackHeaderConfig" was not found in the UIManager when running android app

My component code is given below,

<NavigationContainer>
      <Stack.Navigator 
      screenOptions={{
        headerStyle: {
          backgroundColor: '#f4511e',
        },
        headerTintColor: '#fff',
        headerTitleStyle: {
          fontWeight: 'bold',
        },
      }}
      initialRouteName="Home">
        <Stack.Screen  options={{ title: 'My home' }} name="Home" component={HomeScreen} />
        <Stack.Screen  options={{ title: 'My home' }} name="Details" component={DetailsScreen} />
      </Stack.Navigator>
</NavigationContainer>

Solution 1:

I faced this issue on ios during my work on navigation. The error gets solved after reinstalling all of the navigation packages and running npx pod-install. Before installing the packages I deleted the metro cache, build data, and derived data.


Solution 2:

While following the react-navigation-getting-started-guide, I ran into the same problem after editing the MainActivity.java file in android/app/src/main/java/your package name>/MainActivity.java.

You must turn off the metro-server.

Run react-native run-android after that.


Thank you for reading the article. If you have any suggestions please comment below.