New solution for locked issue #110: Invariant Violation: Tried to register two views with the same name RNCSafeAreaProvider

See original GitHub issue

The old solution: https://github.com/th3rdwave/react-native-safe-area-context/issues/110#issuecomment-668864576

New solution: just run expo install react-native-safe-area-context and then yarn or npm install. Should fix the problem by installing a newer version of react-native-safe-area-context (in my case, 3.1.4).

I would have updated the original issue, but it’s locked.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:11
  • Comments:14

github_iconTop GitHub Comments

18reactions
rossb89commented, Dec 8, 2020

Finally managed to solve this issue, in case anyone else is having the same problem I did. The error was in fact correct that there were 2 versions installed. However, I had previously deleted the wrong one (the one in /node_modules). I’m using expo, and what ended up working was deleting the copy in /node_modules/expo/node_modules/, as well as its reference in package-lock.json.

Yup I had this issue as well, using Expo SDK 39 and react-navigation 4.x

It appears Expo comes with react-native-safe-area-context in it’s own node_modules folder, but react-navigation was complaining about Unable to resolve "react-native-safe-area-context" from "node_modules/react-navigation-stack/lib/module/vendor/views/Stack/StackView.js"

until it was installed with expo install react-native-safe-area-context.

This appeared to work fine with Android when running the app, even though there were now 2 versions present in the dependancy tree after checking with npm list react-native-safe-area-context.

iOS however gave this error described here when booting up the app: Invariant Violation: Tried to register two views with the same name RNCSafeAreaProvider.

For a quick and dirty solution for now, i’ve added "postinstall": "rm -rf node_modules/expo/node_modules/react-native-safe-area-context" under scripts in package.json to remove the Expo one, and now the app is running fine.

I’m sure there must be a better solution out there by someone more versed in this than myself 😃

4reactions
FrankEmirocommented, Jan 18, 2021

i tried everything, no one solution worked in IOS ( didn’t try yet in Android).

i’ve expo bare workflow, expo-cli 3.26.2 and “expo”: “~38.0.8”,

  • deleted node_modules and package.lock or yarn.lock
  • deleted react-native-safe-area-context from Package.json
  • npm or yarn install
  • expo install react-native-safe-area-context
  • cleaned Xcode Build folder
  • used new simulator without cache
  • build with Xcode

same issue:

Screen Shot 2021-01-18 at 2 34 58 PM Screen Shot 2021-01-18 at 2 35 04 PM

please help, is 2 days i m stock!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invariant Violation: Tried to register two views with the same ...
It means you have installed same extension multiple times. Running "npm dedupe" command solved my problem. or Yarn install (The dedupe command ...
Read more >
Invariant Violation: Tried to register two views with the same ...
[Solved]-Invariant Violation: Tried to register two views with the same name RNCSafeAreaProvider error with @react-navigation/stack-Reactjs.
Read more >
Tried to register two views with the same name RNSVGSvgView
I use expo and have installed expo install react-native-svg, and deleted the old, I also removed the node modules and yarn lock and...
Read more >
[Solved] Invariant Violation: Tried to register two views with the ...
How To Solve Invariant Violation: Tried to register two views with the same name RNCSafeAreaProvider Error ? Solution 1: Run this command ......
Read more >
Tried To Register Two Views With The Same Name - ADocLib
New solution for locked issue #110: Invariant Violation: Tried to register two views with the same name RNCSafeAreaProvider #152. New solution for locked...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found