DEV Community

Cover image for Invariant Violation: requireNativeComponent: “RNSScreenStackHeaderSubview” was not found in the UIManager
lens william
lens william

Posted on

Invariant Violation: requireNativeComponent: “RNSScreenStackHeaderSubview” was not found in the UIManager

Image description

Hello developers and enthusiasts of React Native and Expo! Today, let’s discuss an error that you may have encountered or could encounter in the future: “Invariant Violation: requireNativeComponent: ‘RNSScreenStackHeaderSubview’ was not found in the UIManager”.

I recently faced this error while building a mobile application for a client. After running “eas build” and generating the app successfully, it kept crashing upon opening. Interestingly, the app worked fine whenever I served it on Expo Go. Eventually, I had to debug the application and that’s when I came across this error.

In my experience, tracing the parent of the component or the stack and installing the package that uses the component often solved such errors. However, this error was different and my first attempt to find a solution on Stack Overflow and online articles didn’t work. I even tried ChatGPT but to no avail.

If you’re facing this error, the first thing to note is that it’s caused by conflicting dependencies that make use of the react-navigation and react-native-screens packages, or there could be a missing package in your project. To resolve this error, make sure that these packages are installed and up-to-date.

npm i react-navigation react-native-screens @react-native-community/masked-view react-native-gesture-handler react-native-reanimated react-native-safe-area-context

We have another option, which involves deleting the node modules folder and package-lock.json files. Then, we can update all the packages by running the appropriate command.

npm update

I’d like to share another helpful tool called “expo doctor”. It checks that the dependencies installed in your project match the correct versions that your app is using. By appending “-fix-dependencies”, this tool can install the correct versions of the packages used by your app.

expo doctor --fix-dependencies

Once you have completed these steps, rebuild your app and you’ll be one step closer to releasing your application.

Top comments (0)