【问题标题】:react-native: Get error, invariant violation: View config not found of RNSVGCirclereact-native:获取错误,不变违规:未找到 RNSVGCircle 的查看配置
【发布时间】: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


【解决方案1】:

看起来这是一个链接错误。 如果你在 ios 上从你的终端运行:

cd ios && pod install

如果您使用的是 android(RN 版本

react-native link react-native-svg

根据您的 RN 版本和 react-native-svg 库之一,您可能需要更仔细地阅读 installation instructions

【讨论】:

    猜你喜欢
    • 2018-08-04
    • 2023-03-29
    • 1970-01-01
    • 2020-10-28
    • 2019-09-13
    • 2021-02-22
    • 1970-01-01
    • 2018-06-29
    • 1970-01-01
    相关资源
    最近更新 更多