[英]Invalid prop 'children' of type 'array' supplied to overlay. Expected a single react element
It works just fine, and the other answers I've looked at don't really have a solution which can fit mine.它工作得很好,我看过的其他答案并没有真正适合我的解决方案。 What am I doing wrong?我究竟做错了什么?
<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.