简体   繁体   English

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

[英]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.

相关问题 React Native错误失败的道具类型:提供给`Overlay`的`array`类型的无效道具`children`, - React Native error Failed prop type: Invalid prop `children` of type `array` supplied to `Overlay`, 警告:道具类型失败:提供给“提供者”的对象类型为“对象”的道具儿童无效,需要一个ReactElement - Warning: Failed prop type: Invalid prop `children` of type `object` supplied to `Provider`, expected a single ReactElement 反应错误'Failed propType:提供给`Provider`的无效道具`children`,期望一个ReactElement' - React error 'Failed propType: Invalid prop `children` supplied to `Provider`, expected a single ReactElement' 警告:失败的道具类型:提供给`Dropzone`的类型`string`的prop`child`无效,期望的`function` - Warning: Failed prop type: Invalid prop `children` of type `string` supplied to `Dropzone`, expected `function` 提供给“DataProvider”的类型为“number”的无效道具“data”,应为“array”。 React-bootstrap-table2, Firebase 实时数据库 - Invalid prop `data` of type `number` supplied to `DataProvider`, expected `array`. React-bootstrap-table2, Firebase Realtime Database React Native SearchBar错误:道具类型失败:提供给`ForwardRef(TextInput)`的`array`类型的无效道具`value`,预期`string` - React Native SearchBar Error: Failed prop type: Invalid prop `value` of type `array` supplied to `ForwardRef(TextInput)`, expected `string` 获取错误:警告:道具类型失败:提供给“Form”的道具“children”无效,应为 ReactNode - GETTING ERROR : Warning: Failed prop type: Invalid prop `children` supplied to `Form`, expected a ReactNode 失败的道具类型:提供给`Body`的无效道具&#39;app`,期望一个ReactElement - Failed prop type: Invalid prop `app` supplied to `Body`, expected a single ReactElement 道具类型失败:提供给“ForwardRef(DataGrid)”的“object”类型的无效道具“rows”,预期为“array” - Failed prop type: Invalid prop `rows` of type `object` supplied to `ForwardRef(DataGrid)`, expected `array` 道具类型失败:提供给“CSSTransition”的道具“children”无效 - Failed prop type: Invalid prop `children` supplied to `CSSTransition`
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM