gpt4 book ai didi

ios - 不变违规文本字符串必须在 组件内呈现

转载 作者:行者123 更新时间:2023-11-28 23:28:05 26 4
gpt4 key购买 nike

我是 React-Native 开发的新手。每当我尝试使用任何框架时,我都会收到错误

Invariant violation text strings must be rendered within a Text component

我尝试了两个库 react-number-format 和 pichart react-minimal-pie-chart

我知道已经问了很多问题,我尝试了所有问题,但所有问题都与语法问题有关,所以我不得不问,因为我认为这与语法无关,因为代码中没有任何空格。

代码如下:

import React, { Component } from 'react';
import { View } from 'react-native';
import NumberFormat from "react-number-format"
import PieChart from react-minimal-pie-chart

export default class Calculation extends Component {
constructor(props) {
super(props);
this.state = {

};

render() {
return (
<View>
<View style={{ backgroundColor: "lightgray", height: 1, marginHorizontal: 5 }} />
<NumberFormat displayType="text" thousandSeparator={true} thousandsGroupStyle="lakh" prefix={'₹'} value={123456789} />

<PieChart
data={[
{ title: 'One', value: 10, color: '#E38627' },
{ title: 'Two', value: 15, color: '#C13C37' },
{ title: 'Three', value: 20, color: '#6A2135' },
]}
/>
</View>

);
}
}

react-native版本是“0.60.5”

为了引用,我附上了屏幕截图。

enter image description here

提前致谢!!!

最佳答案

好吧...所以在看到你的代码后我没有发现它有什么问题。所以我去检查了您使用的两个库的源代码。

您使用的两个库都不兼容react-native,因为它们是为浏览器的react js制作的,因为它们使用像<div>这样的dom元素。和 <input />

以react-number-format为例,src中的主number_format.js返回

return (
<input
{...inputProps}
ref = {getInputRef}
/>
)

所以,不幸的是你不能将这些库用于react-native。

关于ios - 不变违规文本字符串必须在 <Text> 组件内呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58011912/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com