react-native-svg: ERROR : Native component for "RNSVGLinearGradient" does not exist
Hello everyone, when i use react-native-shadow with react-native-svg , i got same error like this :
Invariant Violation: Native component for “RNSVGLinearGradient” does not exist
This error is located at: in RNSVGLinearGradient (at LinearGradient.js:29) in LinearGradient (at BoxShadow.js:63) in RNSVGDefs (at Defs.js:8) in Defs (at BoxShadow.js:62) in RNSVGSvgView (at Svg.js:94) in Svg (at BoxShadow.js:61) in RCTView (at View.js:112) in View (at BoxShadow.js:60) in BoxShadow (at Card.js:18) in Card (at loginForm.js:12) in LoginForm (at authPage.cmp.js:90) in RCTView (at View.js:112) in View (at authPage.cmp.js:72) in AuthPage (created by Connect(AuthPage)) in Connect(AuthPage) (at Navigation.js:83) in Provider (at Navigation.js:82) in _class2 (at renderApplication.js:35) in RCTView (at View.js:112) in View (at AppContainer.js:102) in RCTView (at View.js:112) in View (at AppContainer.js:122) in AppContainer (at renderApplication.js:34)
I installed this package by : npm i --save react-native-shadow and npm i --save react-native-svg.
Here is my code :
const Card = ({style, children}) => { const shadowOpt = { width:100, height:100, color:"#000", border:2, radius:3, opacity:0.2, x:0, y:3, style:{marginVertical:5} } return( <BoxShadow setting={shadowOpt}> <View style={[styles.cardStyle, style]} > { children } </View> </BoxShadow> ) }
Also maybe need these information :
"react": "16.0.0", "react-native": "0.51", "react-native-shadow": "^1.2.2", "react-native-svg": "^6.3.1",
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 10
- Comments: 25
Same problem , i’ve linked native code through
react-native link react-native-svgit’s still throw an error:
Have you linked it? https://github.com/react-native-community/react-native-svg/blob/master/README.md#installation
react-native link react-native-svg
So, this is probably just linking issues, not a problem with the library, closing…
I have solve this error(must be manual linking, otherwise it will go wrong). The steps are as follows: 1.drag RNSVG.xcodeproj into Libraries directory in XCode. 2.add libRNSVG.a into Link Binary With Libraries 3.rnpm link react-native-svg
restart project in IOS simulator,it’s OK
@SM-Wistful thank you for your answer.
This link solves my problem.
https://www.cnblogs.com/shaoting/p/8085136.htmlIt seems that you have to manually link this library in your IOS project. This is the same as you said.
Having the same issue using ‘react-native-chart-kit’ Linked native code manually per the instructions I can see a related file in my build folder, but the native component is still missing. …\android\app\build\generated\source\r\debug\com\horcrux\svg\R.java
Oh, this was miserable! I don’t really remember how I fixed it, besides messing with the source code and recompiling for a few hours 😕
In terms of linking this is by far the worst library I have had to deal with. When I Archive my Xcode project for submission to the app store, I have to quickly drag RNSVG.a into the build folder manually or else it fails. Euch.
same here, it is happening with other libraries depending on react-native-svg.
pod install