Explanation:
The error message “invariant violation: requirenativecomponent: ‘rnsscreen’ was not found in the uimanager” is related to the React Navigation library. It usually occurs when the required native component for the library is not properly installed or linked.
Possible Solutions:
- Make sure you have installed all the required packages and dependencies for React Navigation. You can do this by running the following command:
- Link the necessary native libraries to your project. If you are using React Native version 0.59 or above, you can use the auto-linking feature by running the following command:
- If the above steps did not resolve the issue, try clearing the cache of your project by running the following commands:
$ npm install react-navigation
$ npx react-native link
If you are using an older version of React Native, you may need to manually link the libraries. You can find the necessary steps in the official React Native documentation.
$ watchman watch-del-all
$ rm -rf node_modules/
$ npm cache clean
$ npm install
After clearing the cache, restart your project and see if the error persists.
Example:
Here is an example of how your package.json file might look with the required packages for React Navigation:
{ "name": "MyApp", "version": "1.0.0", "private": true, "scripts": { "start": "react-native start", "android": "react-native run-android", "ios": "react-native run-ios" }, "dependencies": { "react": "16.13.1", "react-native": "0.63.2", "react-navigation": "^4.4.3", "react-navigation-stack": "^2.10.2" }, "devDependencies": { "@babel/core": "^7.10.4", "@babel/runtime": "^7.10.5", "@react-native-community/eslint-config": "^2.0.0", "babel-jest": "^26.1.0", "eslint": "^7.5.0", "jest": "^26.1.0", "metro-react-native-babel-preset": "^0.61.0", "react-test-renderer": "16.13.1" }, "jest": { "preset": "react-native" } }
Same cateogry post
- [nodemon] clean exit – waiting for changes before restart
- Invariant violation: requirenativecomponent: “rnsscreenstackheaderconfig”
- Error invariant violation: requirenativecomponent: “rnsscreen” was not
- Metro (the local dev server) is run from the wrong folder. check if metro
- Cannot determine project or target for command.