首页 > 解决方案 > 反应原生不断获取文本字符串必须在其中呈现

问题描述

有人可以告诉我为什么我不断收到此错误:

文本字符串必须在组件内呈现

我已经取出了部分 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>
    )
  }     
  }

标签: javascriptreactjsreact-nativerxjs

解决方案


如果它最终具有 type ,则必须将其包装test在组件中。在 react native 中,您只能将文本放在组件中TextstringText

<View>
  <Text>{test}</Text>
<View>

推荐阅读