javascript - 反应原生不断获取文本字符串必须在其中呈现
问题描述
有人可以告诉我为什么我不断收到此错误:
文本字符串必须在组件内呈现
我已经取出了部分 API 密钥。
这是我的代码:-
componentDidMount() {
fetch(
`https://api.nomics.com/v1/currencies/ticker?key=11300ce692510973c&ids&interval=5m,30d&convert=GBP&per-page=100&page=1`
).then((response) => response.json())
.then((data) => {
const ndata = data;
const test = data.map((element) => element);
this.setState({ new: test }); })}
render() {
const test = this.state.new.map((e)=>{return(<SvgUri width="10%" height="10%" source={{uri:e.logo_url}}/>)})
return (
<View>{test}</View>
)
}
}
解决方案
如果它最终具有 type ,则必须将其包装test
在组件中。在 react native 中,您只能将文本放在组件中Text
string
Text
<View>
<Text>{test}</Text>
<View>
推荐阅读
- node.js - 无法通过最新 api 中的示例代码将数据从后端传输到前端
- maven - 将 pom 转换为 build.gradle
- swift - 尝试训练数据模型时出现 Swift CreateML 错误。非常感谢任何输入
- c# - 如何通过一次调用使用 mongo db C# 驱动程序添加嵌套元素或更新属性
- php - 如何从不同的帖子访问 WordPress 帖子缩略图?
- aws-lambda - 如何传递从 SNS 发送的自定义消息/文本以在 Lambda 函数中使用
- django - Django Rest Framework 中的模型翻译
- django - 从 ManyToManyField 数据中添加 ForgeinKey 数据时,“无法通过模型实例访问管理器”
- c++ - 我在 C++ 中构建 node.js 绑定应该 .gitignore *.gypi 文件
- angular - 构建具有多种环境和多种风格的 Angular 应用程序