Invariant violation: requirenativecomponent: “rnsscreen” was not found in the uimanager

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:

  1. Make sure you have installed all the required packages and dependencies for React Navigation. You can do this by running the following command:
  2. $ npm install react-navigation
  3. 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:
  4. $ 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.

  5. If the above steps did not resolve the issue, try clearing the cache of your project by running the following commands:
  6. $ 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

Leave a comment