第一次遇到这样的错误,请耐心等待。
我正在一个项目上,并打开一个文件进行更改。我打开了文件,实际上没有进行任何更改,只是使用Prettier格式化了文件。
格式化后,该项目将以下错误抛出:
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
这是引发错误的代码:
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;
}
我不确定此错误的含义或解决方法。任何的想法?
React Placeholder需要一个子组件。传入其中的任何有效html标记。
<ReactPlaceholder { /*...your other optional props */ }>
<MyComponent /> {/* this is mandatory */ }
</ReactPlaceholder>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句