Skeleton component: fix warning about key prop (https://github.com/woocommerce/woocommerce-blocks/pull/9018)

This commit is contained in:
Luigi Teschio 2023-04-12 16:04:05 +02:00 committed by GitHub
parent e8e7b43625
commit 6c86d45951
1 changed files with 9 additions and 5 deletions

View File

@ -10,11 +10,15 @@ export interface SkeletonProps {
export const Skeleton = ( {
numberOfLines = 1,
}: SkeletonProps ): JSX.Element => {
const skeletonLines = Array( numberOfLines ).fill(
<span
className="wc-block-components-skeleton-text-line"
aria-hidden="true"
/>
const skeletonLines = Array.from(
{ length: numberOfLines },
( _: undefined, index ) => (
<span
className="wc-block-components-skeleton-text-line"
aria-hidden="true"
key={ index }
/>
)
);
return (
<div className="wc-block-components-skeleton">{ skeletonLines }</div>