Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Invariant Violation: requireNativeComponent: "RNSScreen" was not found in the UIManager.' error in react native cli

I keep getting RNSScreen error. I have followed all instructions on react-navigation guide but nothing has worked for me.

like image 506
error Avatar asked Jan 25 '26 23:01

error


1 Answers

Looks like native packages are not linked automatically. So try this

Note: In your case it can be '../' instead of '../../../' because I am using Monorepo.

Podfile

pod 'RNScreens', :path => '../../../node_modules/react-native-screens/'
pod 'RNGestureHandler', :path => '../../../node_modules/react-native-gesture-handler/'
pod 'react-native-safe-area-context', :path => '../../../node_modules/react-native-safe-area-context/'

Then Install pods

yarn podinstall

Then terminate already running MetroBundler terminal. And, build app again

yarn ios

Working Example

/**
 * @format
 */
import 'react-native-gesture-handler';
import {AppRegistry} from 'react-native';

import SplashScreen from '../common/src/containers/splashScreen';
import LoginScreen from '../common/src/containers/loginScreen';
import LoginOTPScreen from '../common/src/containers/loginOTPScreen';
import SearchScreen from './src/searchScreen';

import React from 'react';
import {name as appName, displayName} from './app.json';
import {Provider as PaperProvider} from 'react-native-paper';
import {NavigationContainer} from '@react-navigation/native';
import {createStackNavigator} from '@react-navigation/stack';

import {enableScreens} from 'react-native-screens';
enableScreens();

const Stack = createStackNavigator();
const App = () => {
  return (
    <PaperProvider>
      <NavigationContainer>
        <Stack.Navigator initialRouteName="SplashScreen">
          <Stack.Screen name="SplashScreen" component={SplashScreen} />
          <Stack.Screen name="LoginScreen" component={LoginScreen} />
          <Stack.Screen name="LoginOTPScreen" component={LoginOTPScreen} />
          <Stack.Screen name="SearchScreen" component={SearchScreen} />
        </Stack.Navigator>
      </NavigationContainer>
    </PaperProvider>
  );
};

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

Make sure import 'react-native-gesture-handler'; is the top

like image 164
illusionist Avatar answered Jan 28 '26 16:01

illusionist



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!