javascript - react-native:获取错误,不变违规:未找到 RNSVGCircle 的查看配置
问题描述
好的,基本上我一次将许多库导入到一个项目中,并一个一个地尝试它们。现在我试图让 SVG 工作(谷歌登录和手势处理程序相应地工作),但是在运行这段代码之后:
**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React, { useState } from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
StatusBar,
Text,
} from 'react-native';
import Svg, { Circle } from 'react-native-svg';
import {
TapGestureHandler,
LongPressGestureHandler,
State
} from 'react-native-gesture-handler'
import OneSignal from 'react-native-onesignal'
import {
GoogleSignin,
GoogleSigninButton,
statusCodes,
} from '@react-native-community/google-signin';
//aa
import RNlocalize from 'react-native-localize'
import YouTube from 'react-native-youtube';
//import Share from 'react-native-share';
const App: () => React$Node = () => {
const [text, setText] = useState('Yass')
const _handleStateChange = ({ nativeEvent }) => {
if (nativeEvent.state === State.ACTIVE) {
setText('Long Press')
}
if (nativeEvent.state === State.END) {
setText('Back to Yass')
}
}
return (
<View>
<View style={{ padding: 80 }}>
<GoogleSigninButton //a
style={{ width: 192, height: 48 }}
size={GoogleSigninButton.Size.Wide}
color={GoogleSigninButton.Color.Dark}
/>
<Text>HOLAaApessssnesdsdA</Text>
<LongPressGestureHandler onHandlerStateChange={_handleStateChange}>
<Text style={styles.buttonText}>Longpress me</Text>
</LongPressGestureHandler>
<Text>{text}</Text>
</View>
<View>
<Svg height="100" width="100">
<Circle cx="50" cy="50" r="50" fill="pink" />
</Svg>
</View>
</View>
);//a
};
const styles = StyleSheet.create({
buttonText: {
borderWidth: 1,
}
});
export default App;
以下错误跳转
ExceptionsManager.js:44 Invariant Violation: requireNativeComponent: "RNSVGCircle" was not found in the UIManager.
This error is located at:
in RNSVGCircle (at Circle.tsx:24)
in Circle (at App.js:71)
in RNSVGGroup (at G.tsx:28)
in G (at Svg.tsx:170)
in RNSVGSvgView (at Svg.tsx:157)
in Svg (at App.js:70)
in RCTView (at App.js:69)
in RCTView (at App.js:56)
in App (at renderApplication.js:40)
in RCTView (at AppContainer.js:101)
in RCTView (at AppContainer.js:119)
in AppContainer (at renderApplication.js:39)
尝试将库读取到项目中,重新安装甚至手动将 RNSVG podspec 添加到我的 podfile 中。我现在没有想法。
ps:我是 React Native 的新手,对我来说可能只是一个愚蠢的错误,所以请多多包涵并提前感谢
解决方案
it looks like this is a link error. If you're on ios run from your terminal :
cd ios && pod install
If you're on android (with a RN version < 0.60) :
react-native link react-native-svg
You might need, depend on your RN version and on the one of react-native-svg library, to read more carefully the installation instructions.
推荐阅读
- pandas - 如何在groupby之后反转值
- javascript - How to access and modify a text file in github from an express server?
- r - How can I write function with this condition?
- linux - how to send a variable plus string using expect
- angular - 在 Angular 中的父组件和子组件之间传递相同的数据
- java - 在 Spring Batch 中暂停多线程执行
- java - CLASSPATH 中的多个冒号
- python - Python - 管理嵌套的 JSON 到 DataFrame
- amazon-web-services - AWS MWAA:某些提供的配置没有预期的格式:调度程序,例如:core.log_format
- node.js - AWS Transcribe 客户端不提供名为“transcribeClient”的导出