software-mansion / react-native-svg

SVG library for React Native, React Native Web, and plain React web projects.
MIT License
7.43k stars 1.12k forks source link

Tried to register two views with the same name RNSVGPath #591

Closed obetomuniz closed 6 years ago

obetomuniz commented 6 years ago

As you can see in the screenshot, I get the issue when I tried use 2 libraries that use react-native-svg as dependency. I'm using RN 0.52 and RN-svg 6.0.1-rc.2

simulator screen shot - iphone 6 - 2018-01-30 at 12 11 31

msand commented 6 years ago

Probably similar issue to this: https://stackoverflow.com/questions/46613149/tried-to-register-two-views-with-the-same-name-progressbarandroid and https://github.com/invertase/react-native-firebase/commit/54c92d0640e8765e4ab3d624dc1577bcc4ed7bfa

ewalti commented 6 years ago

I'm back on 5.5.1 on my project but wanted to try 6.x to see if it would fix some other issues I was having. Rolling up caused this same conflict at first, because I seemingly had another library requiring the old version (react-native-pathjs-charts) and 6.x. I removed that library, as I was no longer using it, rm -rf node_modules, yarn, react-native link, and the issue went away.

sibelius commented 6 years ago

this happens when another lib has this package as a dependency, we can close this

msand commented 6 years ago

Alright, I'll go ahead and close this.

HarmJan1990 commented 6 years ago

Hi there,

I get this error but i only have react-native-svg included once. There is no other library that requires it in my project but i still get this error. Any clues?

yogeshR5 commented 6 years ago

+1

viewsing commented 6 years ago

Expo also has the react-native-svg, so I remove the react-native-svg when using Expo, the error is gone

jean-noelp commented 6 years ago

Removing react-native-svg is just a workaround. Me, i need last version of react-native-svg too, how to do that ?

matteocollina commented 6 years ago

Same issue react-native-cli: 2.0.1 react-native: 0.55.4

npm list react-native react-native-svg : schermata 2018-09-05 alle 21 40 19

tmswartz12 commented 5 years ago

Getting this issue. Is there a working solution?

sftgf commented 5 years ago

+1

msand commented 5 years ago

If you're using yarn, then you can use resolutions: https://yarnpkg.com/en/docs/package-json#toc-resolutions E.g. if you're using react-native-svg v8.0.8 and want to override it in all your dependencies, add this to your package.json file and run yarn again:

  "resolutions": {
    "react-native-svg": "8.0.8"
  }

Or, if you're using npm, then you can run: https://www.npmjs.com/package/npm-force-resolutions#how-to-use

rm -r node_modules
npx npm-force-resolutions
npm install
vjsingh commented 5 years ago

This seems to be a new issue in Expo 31? None of the fixes in this thread worked for me

msand commented 5 years ago

@vjsingh Expo already includes react-native-svg, you shouldn't add it as a dependency.

vjsingh commented 5 years ago

@msand Thanks for the advice. I'm not sure what it was since I removed my dependency on react-native-svg. It may be related to https://github.com/JesperLekland/react-native-svg-charts which I used, but that library appears to load react-native-svg as a peer dependency which looks to be the right way to do it?

Anyway, for now I am just going to stick with Expo 30 until I have some more time. Thank you again for the help.

abduraufsherkulov commented 5 years ago

I have a similar issue here. Expo 32, as soon as it renders the component, expo crashes.

msand commented 5 years ago

@abduraufsherkulov if you use expo, then this library comes built in and you shouldn't add it as a dependency, also make sure none of your other dependencies depend on it. Or, eject the project.

vjsingh commented 5 years ago

I'm not sure if I set my package.json wrong somehow, but after upgrading to Expo 31 I had to change all imports of react-native-svg in a package I depend on to import from Expo instead.

https://github.com/vjsingh/react-native-svg-charts/commit/298f3718b147358a68f07a1104d657ab1540bf86

msand commented 5 years ago

That sounds correct, Expo should probably change their setup, such that they also expose the react-native-svg module.

msand commented 5 years ago

You can find examples of ejecting from expo: https://github.com/msand/InfiniDrawExpo to ExpoKit: https://github.com/msand/InfiniDrawExpo/tree/expokiteject or to plain react-native: https://github.com/msand/InfiniDrawExpo/tree/nativeeject And the original project which has both web (using react-native-web) and plain react-native here: https://github.com/msand/InfiniDraw/

gtiongco95 commented 5 years ago

I've tried removing the react-native-svg dependency and updated my imports to use expo instead but when I run my app I get a: "React.isMemo is not a function. (In 'React.isMemo(component)', 'React.isMemo' is undefined)"

Has anyone else experienced this or know what is wrong?

msand commented 5 years ago

Are you using react-redux or react-is? Perhaps this thread can help you: https://github.com/zeit/next.js/issues/6117

gtiongco95 commented 5 years ago

Using react-redux. Tried the approach of pinning my version to 4.4.9 from 5.1.0 which it was initially. However, I'm met with other issues so don't really think that would be a feasible approach for me..

EDIT making the changes to use expo's svg, clearing node_modules, removing package-lock.json, running npm install and running expo start -c (with the clear cache flag) worked for me.

lylest commented 5 years ago

i am still facing the same issue

akshaygore06 commented 5 years ago
 npmPackages:
      react: 16.8.6 => 16.8.6 
      react-native: ^0.59.5 => 0.59.8 
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-git-upgrade: 0.2.7
      react-native-shimmer: 0.5.0
      react-native: 0.59.8

still facing same issue.. tried npm-force-resolutions but no results.

Screen Shot 2019-05-14 at 10 35 59 AM

astw commented 5 years ago

My case, If I remove react-native-svg, I got an error complaining there is no react-native-svg, If I include I got 'register two views with the same name RNSVGPath' error. npm-force-resolutions doesn't help.

martinfrouin commented 5 years ago

I'm facing this issue as well [fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: Tried to register two views with the same name RNSVGPath

I'm using react-native@0.59.9 and react-native-svg@5.5.1

I'm not using Expo, and the @msand solution doesn't work for me.

Please reopen this issue

msand commented 5 years ago

Can you make a minimal reproduction first?

Jimexa commented 5 years ago

@astw I am facing the same issue. Have you figured it out yet?

dragslag commented 5 years ago

@Jimexa I went through every file in react-native-svg-charts and changed import Svg {Line, etc,etc} from 'react-native-svg' to import Svg {Line, etc, etc} from 'expo' and that works for now.

vjsingh commented 5 years ago

@dragslag You may want to look into Victory charts. I used react-native-svg-charts for a while, and it's a great library but not actively maintained anymore. The switch didn't take too long

dragslag commented 5 years ago

Thanks @vjsingh I'll check it out

Vincetroid commented 5 years ago

What should you do if you want to use react-native-qrcode-svg in Expo?

RikusWiehahn commented 5 years ago

How I fixed this:

  1. Make sure react-native-svg is not in package.json
  2. Delete package-lock.json
  3. Delete node_modules
  4. Run npm install
nandorojo commented 4 years ago

expo-install react-native-svg caused this issue for me since it appears to install the wrong version. This fixed it:

rm -rf node_modules
npm i react-native-svg@9.11.1
npm i
expo start -c

Answer from StackOverflow

chanonroy commented 4 years ago

I was able to solve this issue by installing the appropriate version using:

expo install react-native-svg
Egizas commented 4 years ago

My case, If I remove react-native-svg, I got an error complaining there is no react-native-svg, If I include I got 'register two views with the same name RNSVGPath' error. npm-force-resolutions doesn't help.

I have exactly the same situation. Did you manage to solve it?

chanonroy commented 4 years ago

My case, If I remove react-native-svg, I got an error complaining there is no react-native-svg, If I include I got 'register two views with the same name RNSVGPath' error. npm-force-resolutions doesn't help.

I have exactly the same situation. Did you manage to solve it?

@Egizas, try installing using expo install react-native-svg and then reference it as seen here

daihovey commented 3 years ago

This issue is back in 1.6.5

"dependencies": {
    ...
    "react-native-svg": "9.6.4",
    ...
  },
dcsan commented 2 years ago

I have a similar issue.

if i remove it from package.json the app will complain it doesn't exist if i add it, i get the duplication error

$ yarn why react-native-svg   
yarn why v1.22.19
warning ../../../../package.json: No license field
[1/4] 🤔  Why do we have the module "react-native-svg"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "react-native-svg@12.3.0"
info Has been hoisted to "react-native-svg"
info This module exists because it's specified in "dependencies".
info Disk size without dependencies: "18.59MB"
info Disk size with unique dependencies: "20.15MB"
info Disk size with transitive dependencies: "22.29MB"
info Number of shared dependencies: 3
=> Found "@walletconnect/react-native-dapp#react-native-svg@9.6.4"
info This module exists because "@walletconnect#react-native-dapp" depends on it.
info Disk size without dependencies: "1.54MB"
info Disk size with unique dependencies: "1.54MB"
info Disk size with transitive dependencies: "1.54MB"
info Number of shared dependencies: 0
✨  Done in 0.34s.

so there are two versions, the peer dep of another package is using an older version. if i install that version at the top level it now works:

yarn add react-native-svg@9.6.4

✅ ok from then

R-Art-project commented 1 year ago

moving react-native-svg towards the peerDependencies solved this problem for me.

"peerDependencies": { "react-native-svg": "13.8.0" },

AftabUfaq commented 8 months ago

this issue is basically due to the different react-native-svg dependencies. for example I was using a package react-native-cool-speedometer it was using a different version 12.x.x and I was using 13.5.0 after upgrading the react-native-coolspeedometer it was going

Aswanth-c commented 7 months ago

I had the same issue. I had to uninstall the react-native-svg package using the npm command but at the same time, it caused another issue, which is "Invariant Violation: requireNativeComponent: "RNSVGPath" was not found in the UIManager." then I did an expo install react-native-svg instead of npm install react-native-svg Which fixes the issue

mad-dogy commented 3 months ago

Make sure you set the width and height for the svg icon

I had the same issue and it helps me :)