react-native-svg-flagkit icon indicating copy to clipboard operation
react-native-svg-flagkit copied to clipboard

Invariant Violation caused by react-native-svg dependency

Open choibles opened this issue 5 years ago • 1 comments

Hey there –

First off, thanks for the library!

Had a puzzling FATAL crash recently occur when building my react-native iOS app, which makes use of react-native-svg-flagkit. I hadn't seen this issue before yesterday.. so it's possibly related to some updates in OS/SDK? (running macOS 10.15.4 and Xcode 11.5).

The error read: Unhandled JS Exception: Invariant Violation: Tried to register two views with the same name RNSVGRect

Sounded like a duplicate reference to react-native-svg, which was possible if one of my npm packages was pulling it in, since I'd already included react-native-svg in my own package.json.

After some investigation, I noticed that this library was pulling in react-native-svg into its own /node_modules folder, and after I deleted this "duplicate" module with the following command, the build worked:

rm -rf node_modules/react-native-svg-flagkit/node_modules/react-native-svg

Credit to this thread which tipped me off to the issue. Also appears that updating react-native-svg to a peer dependency (per this pull request) could potentially address the issue for the future.

Just wanted to leave an FYI for anyone experiencing the same issue, as well as document a potential fix for the package maintainers.

Cheers

choibles avatar Jun 28 '20 21:06 choibles

Thank you for sharing your solution here. I encountered the same issue.

potatowave avatar Jul 04 '20 18:07 potatowave