React-native-screens: Tried to register two views with the same name RNSScreen

Created on 20 Sep 2018  路  20Comments  路  Source: software-mansion/react-native-screens

Getting the following issue when I add import { useScreens } from 'react-native-screens'; in my App.js

simulator screen shot - iphone se - 2018-09-20 at 15 25 00

simulator screen shot - iphone se - 2018-09-20 at 15 25 02

react-native info

Environment:
OS: macOS High Sierra 10.13.5
Node: 10.10.0
Yarn: 1.9.4
npm: 6.4.1
Watchman: 4.9.0
Xcode: Xcode 9.4.1 Build version 9F2000
Android Studio: Not Found

Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: https://github.com/expo/react-native/archive/sdk-30.0.0.tar.gz => 0.55.4

Etc

"expo": "^30.0.0",
"react-native-screens": "^1.0.0-alpha.12",

Happens in both dev and production mode
Was not able to reproduce in a simple snack

Most helpful comment

I deleted the react-native-gesture-handler from node_modules/expo/ and it worked for me. It took me so much time to figure it.

All 20 comments

I had the same issue but with the app created with react-native init

I'm also running into this issue using in an ejected CRNA app alongside react-navigation: "2.14.0".

The app I'm working on uses multiple types of nested navigators (stack, switch, drawer, tab) and has multiple stack navigators. I wonder if having multiple navigators setup is part of the issue here?

The issue is related to the fact react-native-screens package is installed several times under node_modules in different versions. I am investigating a possible cause of this but one hint that I have for the time being is to try upgrading yarn and performing a clean install with yarn instead of npm

@kmagiera what do you mean by "installed several times under node_modules"?

@kmagiera any solution for that?

error appears when upgrading react-navigation to v2.16.0. Since react navigation uses react-native-screens.

So, related to this:

can't really investigate it more atm, but yeah there is probably something with a clash.

^ Bumping react-native-screens for 2.x in a fork of react-navigation addressed this issue for me: https://github.com/lanceharper/react-navigation/commit/1df42a41c17769a87c5532d2dc8afa7847162cce

I can submit this back to the main repo if there is no preferred alternative.

2.x of react-navigation depends on ^1.0.0-alpha.11 which should match 1.0.0-alpha.15. however, another package has installed react-native-screens with a more strict dependency that doesn't match this range, for example if your package.json explicitly includes [email protected], then you will end up with 2 copies of react-native-screens. i'd check your yarn.lock to see what package is installing which version of it.

useful reference:
https://semver.npmjs.com/
screen shot 2018-10-23 at 1 18 07 pm

(update: with ReactNav v3 the issue disappears 馃憣)

Had the same issue, with Expo 31.0.5 and RN 2.18.2.
Solved the issue by removing react-native-screens from my own dependencies. (ie using the already required version of rn-screens.

"dependencies": {
  "expo": "^31.0.4",
  "react": "16.5.0",
  "react-native": "https://github.com/expo/react-native/archive/sdk-31.0.1.tar.gz",
  "react-navigation": "^2.18.0"
}

Is there a way to solve this error when using reac-native-screens as a local_module?

I'm currently trying to fix this library for tvOS but because it is a dependency now of @react-navigation/native I always get this error now. Probably because it gets loaded twice (once from local_module and once for as a dependency for react-navigation)

Any tips for that?

I deleted the react-native-gesture-handler from node_modules/expo/ and it worked for me. It took me so much time to figure it.

@ranjitatwal30 , thanks a lot man , it saves e a lot of time :+1:

@ranjitatwal30 it works for me too !!! thank you !!!

I deleted the react-native-gesture-handler from node_modules/expo/ and it worked for me. It took me so much time to figure it.

it works!

I deleted the react-native-gesture-handler from node_modules/expo/ and it worked for me. It took me so much time to figure it.

thank u.

For people not using Expo:

I had the problem with react-navigation. I checked in yarn.lock what was the exact version of react-native-screensused by the react-navigation package and installed EXACTLY the same version and now it works !

My yarn.lock was:

react-native-screens@^1.0.0-alpha.11:
  version "1.0.0-alpha.15"
  resolved "https://registry.yarnpkg.com/react-native-screens/-/react-native-screens-1.0.0-alpha.15.tgz#5b5a0041310b46f12048fda1908d52e7290ec18f"

So i installedyarn add react-native-screens@^1.0.0-alpha.11

Can someone tell if the issue still exists in the newer versions of Expo and Screens?

I am closing it due to no response in more than 30 days. Feel free to comment to reopen it.

Was this page helpful?
0 / 5 - 0 ratings