【发布时间】:2020-01-22 04:43:17
【问题描述】:
好的,基本上我一次将许多库导入到一个项目中,并一个一个地尝试它们。现在我试图让 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 的新手,我可能只是一个愚蠢的错误,所以请多多包涵,提前感谢
【问题讨论】:
-
安装库后是否在 ios 目录中运行过 'pod install' 命令?
-
必须用 npx react-native run-ios 运行项目,从 XCode 运行是行不通的。我认为一些链接是通过命令完成的,而不是通过 XCode 运行...
标签: javascript ios reactjs react-native