对于也可能返回string或直接返回其children的React组件,除了JSX.Element之外,哪种类型是正确的?PropsStringExample = Readonly<{}>;
children: React.ReactNodeundefined' is not assignable to ty
我收到一个阻止编译的错误。我可以将any添加到StoriesComponent返回类型中,然后一切正常工作。然而,我听说这不是很好的练习(我对TS很陌生)。我想在这里返回一个Story元素数组,所以我确定编译错误消息是如何指向正确的方向的。有什么想法吗?以下为参考:JSX element type 'Element[]' is not a constructor function for JSX