繁体   English   中英

提供给叠加层的“数组”类型的道具“子项”无效。 期望单个反应元素

[英]Invalid prop 'children' of type 'array' supplied to overlay. Expected a single react element

它工作得很好,我看过的其他答案并没有真正适合我的解决方案。 我究竟做错了什么?

  <Overlay
  isVisible={this.state.isVisible}
  onBackdropPress={() => this.setState({ isVisible: false })}
>
  {
    this.state.userSlugs.map((l, i) => (
    <WebView key = {i}
    source={{uri: 'https://myurl.com'+l}}
    style={{marginTop: 20}}
    injectedJavaScript={`const meta = document.createElement('meta'); 
    meta.setAttribute('content', 'width=device-width, initial-scale=0.3,
     maximum-scale=0.3, user-scalable=0'); meta.setAttribute('name', 'viewport'); 
     document.getElementsByTagName('head')[0].appendChild(meta); `}
    scalesPageToFit={false}
  />
    ))
  }
</Overlay>

正如我在评论中提到的,您需要将WebView包装到某个容器中,因为您将一组子项传递给Overlay ,但它只需要一个子项。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM