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