简体   繁体   English

失败的道具类型:提供给“ForwardRef(Grid)”的无效道具“children”

[英]Failed prop type: Invalid prop `children` supplied to `ForwardRef(Grid)`

This is just one example of the issue, I am able to create the issue using many elements.这只是问题的一个例子,我可以使用许多元素来创建问题。 When replacing child components of a element what is the correct approach so as not to get Invalid prop children supplied to `ForwardRef?替换元素的子组件时,正确的方法是什么,以免将 Invalid prop children提供给`ForwardRef?

const dynamicJSX = () => {
  return (
    <div>Working</div>
  )
}

return (
  <Grid container >
    <Grid item >
      {dynamicJSX}
    </Grid>
  </Grid>
)

You should use <dynamicJSX /> instead of passing its reference.您应该使用<dynamicJSX />而不是传递它的引用。 This way, you probably want to rename it to <DynamicJSX /> (for convention).这样,您可能希望将其重命名为<DynamicJSX /> (为了约定)。

You can also call {dynamicJSX()} if dynamicJSX has more a role of util rendering method rather than a functional component.如果dynamicJSX更多的是 util 渲染方法而不是功能组件,您也可以调用{dynamicJSX()}

暂无
暂无

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

相关问题 失败的道具类型:提供给“ForwardRef(Grid)”的无效道具“lg” - Failed prop type: Invalid prop `lg` supplied to `ForwardRef(Grid)` 警告:失败的道具类型:提供给“ForwardRef(网格)”的无效道具“xs” - 材质 UI 网格中的错误 - Warning: Failed prop type: Invalid prop `xs` supplied to `ForwardRef(Grid)` - Error in Material UI Grid 警告:失败的道具类型:提供给“ForwardRef(Select)”的无效道具“children”,需要一个ReactNode - Warning: Failed prop type: Invalid prop `children` supplied to `ForwardRef(Select)`, expected a ReactNode 失败的道具类型:提供给 `ForwardRef(Select)` 的无效道具 `children`,需要一个 ReactNode - Failed prop type: Invalid prop `children` supplied to `ForwardRef(Select)`, expected a ReactNode 警告:道具类型失败:提供给 `ForwardRef(Slider)` 的道具 `value` 无效 - Warning: Failed prop type: Invalid prop `value` supplied to `ForwardRef(Slider)` 失败的道具类型:提供给`GlobalState`的`array`类型的无效道具`children` - Failed prop type: Invalid prop `children` of type `array` supplied to `GlobalState` 道具类型失败:提供给“CSSTransition”的道具“children”无效 - Failed prop type: Invalid prop `children` supplied to `CSSTransition` 道具类型失败:提供给“ForwardRef(InputBase2)”的“符号”类型的道具“类型”无效,应为“字符串” - Failed prop type: Invalid prop `type` of type `symbol` supplied to `ForwardRef(InputBase2)`, expected `string` 警告:道具类型失败:提供给“ForwardRef(FormControl)”的“string”类型的道具“error”无效,预期为“boolean” - Warning: Failed prop type: Invalid prop `error` of type `string` supplied to `ForwardRef(FormControl)`, expected `boolean` reactjs 失败的道具类型:提供给“ForwardRef(IconButton)”的“object”类型的无效道具“className”,应为“string” - reactjs Failed prop type: Invalid prop `className` of type `object` supplied to `ForwardRef(IconButton)`, expected `string`
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM