Skip to content

Commit aae71ba

Browse files
ickasclaude
andcommitted
fix: add missing keys to Table skeleton elements
The skeleton loading state was rendering elements without React keys, causing "Each child in a list should have a unique key prop" warnings. Added proper keys to: - Skeleton header cells - Skeleton rows - Skeleton cells Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b8b4631 commit aae71ba

1 file changed

Lines changed: 12 additions & 20 deletions

File tree

src/molecules/table/index.tsx

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,6 @@ const Table = <CellData extends CellBaseType>(props: TableProps<CellData>) => {
7272
const hasActionMenu = actions.length > 0;
7373
const validValues = values.filter(hasValue);
7474
const hasValues = Array.isArray(values) && values.length > 0;
75-
76-
const headSkeleton = (
77-
<th>
78-
<Styles.SkeletonCell />
79-
</th>
80-
);
81-
82-
const cellSkeleton = (
83-
<td>
84-
<Styles.SkeletonCell />
85-
</td>
86-
);
87-
8875
const columnsSkeleton = columns.length > 0 ? columns.length : loadingColumns;
8976

9077
if (showEmpty && !hasValues) {
@@ -111,7 +98,11 @@ const Table = <CellData extends CellBaseType>(props: TableProps<CellData>) => {
11198
<thead>
11299
<tr>
113100
{loading && !columns
114-
? Array.from({ length: loadingColumns }, () => headSkeleton)
101+
? Array.from({ length: loadingColumns }, (_, i) => (
102+
<th key={`skeleton-head-${i}`}>
103+
<Styles.SkeletonCell />
104+
</th>
105+
))
115106
: columns.map(
116107
({
117108
id = '',
@@ -135,12 +126,13 @@ const Table = <CellData extends CellBaseType>(props: TableProps<CellData>) => {
135126
</thead>
136127
<tbody>
137128
{loading
138-
? Array.from({ length: loadingRows }, () => (
139-
<tr>
140-
{Array.from(
141-
{ length: columnsSkeleton },
142-
() => cellSkeleton
143-
)}
129+
? Array.from({ length: loadingRows }, (_, rowIndex) => (
130+
<tr key={`skeleton-row-${rowIndex}`}>
131+
{Array.from({ length: columnsSkeleton }, (_, colIndex) => (
132+
<td key={`skeleton-cell-${rowIndex}-${colIndex}`}>
133+
<Styles.SkeletonCell />
134+
</td>
135+
))}
144136
</tr>
145137
))
146138
: validValues.map((row, index) => (

0 commit comments

Comments
 (0)