[英]Typescript error: Property 'children' is missing in type but required in type 'CommonProps'
First time seeing an error like this so please bear with me.第一次看到这样的错误,请多多包涵。
I was working on a project and opened one file to make a change.我正在处理一个项目并打开一个文件进行更改。 I opened the file, didn't actually make any change and just formatted the file using Prettier.
我打开了文件,实际上并没有做任何更改,只是使用 Prettier 格式化了文件。
Right when it formatted, the project threw the error below:就在它格式化时,该项目引发了以下错误:
TypeScript error in C:/Users/name/source/repos/UsedEquipment/src/pages/listings/sections/SearchResultListings.tsx(253,16):
Type '{ style: { height: string; }; type: "rect"; ready: false; showLoadingAnimation: true; }' is not assignable to type '(IntrinsicAttributes & CommonProps & { color?: string | undefined; rows?: number | undefined; showLoadingAnimation?: boolean | undefined; customPlaceholder?: undefined; } & Pick<...> & { ...; } & { ...; }) | ... 4 more ... | (IntrinsicAttributes & ... 2 more ... & { ...; })'.
Property 'children' is missing in type '{ style: { height: string; }; type: "rect"; ready: false; showLoadingAnimation: true; }' but required in type 'CommonProps'. TS2322
Here's the code where the error's thrown:这是引发错误的代码:
showPlaceholders() {
let items: Object[] = [];
for (let i = 0; i < ITEMSPERPAGE; i++) {
//show # of placeholders
items.push(
<div
className="productwrap col-xs-12 col-sm-4 col-md-4 col-lg-3 placeholder"
key={i}
>
<div className="product-wrapper">
<div className="product-image">
<ReactPlaceholder
^ Error thrown here
style={{ height: "180px" }}
type="rect"
ready={false}
showLoadingAnimation={true}
></ReactPlaceholder>
</div>
<div className="product-info-column">
<ReactPlaceholder
^ Error thrown here
type="text"
rows={6}
ready={false}
showLoadingAnimation={true}
></ReactPlaceholder>
</div>
</div>
</div>
);
}
return items;
}
I'm not entirely sure what this error means or how to fix it.我不完全确定这个错误是什么意思或如何解决它。 Any idea?
任何想法?
React Placeholder expects one child component . React Placeholder 需要一个子组件。 Pass in any valid html tag inside it.
在其中传入任何有效的 html 标签。
<ReactPlaceholder { /*...your other optional props */ }>
<MyComponent /> {/* this is mandatory */ }
</ReactPlaceholder>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.