React native 获取不变冲突:元素类型无效:react native中的曲面需要字符串,但我的导入是正确的

React native 获取不变冲突:元素类型无效:react native中的曲面需要字符串,但我的导入是正确的,react-native,React Native,我一直在尝试制作一个非常基本的surface/react艺术样品并运行。但是每次我尝试使用时,它都会给我一个不变的冲突。我没有在任何地方使用默认导出。我已经安装了art插件,并通过react native link将其链接起来,然后重新启动/重建了所有内容,但我仍然收到相同的错误。我还尝试从react native导入艺术,然后从中获取表面,但也失败了。现在我正在使用iOS模拟器进行测试,使用的是react native run iOS import {PureComponent} from '

我一直在尝试制作一个非常基本的surface/react艺术样品并运行。但是每次我尝试使用
时,它都会给我一个不变的冲突。我没有在任何地方使用默认导出。我已经安装了art插件,并通过
react native link
将其链接起来,然后重新启动/重建了所有内容,但我仍然收到相同的错误。我还尝试从react native导入艺术,然后从中获取表面,但也失败了。现在我正在使用iOS模拟器进行测试,使用的是
react native run iOS

import {PureComponent} from 'react';
import {Group, Shape, Surface, View} from 'react-native';
import React from 'react';

export class Chart extends PureComponent {
    render() {
        return <View>
            <Surface width={100} height={100}>
            </Surface>
        </View>;
    }
}

我想你没有把图书馆链接好

要正确链接它,您需要首先导航到
节点\u modules/react native/Libraries/ART/
并找到
ART.xcodeproj

确保在Xcode中打开项目,然后将
ART.xcodeproj
拖动到
Libraries
列表中

然后,您需要将
libArt.a
Art.xcodeproj
中的products文件夹拖动到链接的框架和库中

然后在您的
App.js
中,我们可以执行以下操作:

import React, {Component} from 'react';
import { StyleSheet, View, ART } from 'react-native';
// notice that we import ART and then we can full the values Group, Shape and Surface out of ART
const { Group, Shape, Surface } = ART;

type Props = {};
export default class App extends Component<Props> {
  render() {
    return (
      <View style={styles.container}>
        <Surface width={200} height={200}>
        <Group x={0} y={0}>
          <Shape d={"M10 80 C 40 10, 65 10, 95 80 S 150 150, 180 80"} stroke="#000" strokeWidth={1} />
        </Group>
      </Surface>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  }
});
import React,{Component}来自'React';
从“react native”导入{StyleSheet,View,ART};
//请注意,我们导入了艺术,然后我们可以从艺术中填充值组、形状和曲面
常数{群,形,面}=艺术;
类型Props={};
导出默认类应用程序扩展组件{
render(){
返回(
);
}
}
const styles=StyleSheet.create({
容器:{
弹性:1,
为内容辩护:“中心”,
对齐项目:“居中”,
背景颜色:“#F5FCFF”,
}
});
这将为我们提供以下输出:


就这样了,谢谢,希望它的错误稍微好一点
import React, {Component} from 'react';
import { StyleSheet, View, ART } from 'react-native';
// notice that we import ART and then we can full the values Group, Shape and Surface out of ART
const { Group, Shape, Surface } = ART;

type Props = {};
export default class App extends Component<Props> {
  render() {
    return (
      <View style={styles.container}>
        <Surface width={200} height={200}>
        <Group x={0} y={0}>
          <Shape d={"M10 80 C 40 10, 65 10, 95 80 S 150 150, 180 80"} stroke="#000" strokeWidth={1} />
        </Group>
      </Surface>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  }
});