Skip to content

Commit e2482f7

Browse files
committed
fix(FieldRender): 将 dataIndex 强制转换为 React.Key 以确保类型安全
1 parent 7881583 commit e2482f7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

packages/descriptions/src/index.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ export const FieldRender: React.FC<
269269
},
270270
{
271271
isEditable: true,
272-
recordKey: dataIndex,
272+
recordKey: dataIndex as React.Key,
273273
record: form.getFieldValue(
274274
[dataIndex].flat(1) as (string | number)[],
275275
),
@@ -296,7 +296,7 @@ export const FieldRender: React.FC<
296296
gap: token.marginXS,
297297
}}
298298
>
299-
{editableUtils?.actionRender?.(dataIndex || index, {
299+
{editableUtils?.actionRender?.((dataIndex as React.Key) || index, {
300300
cancelText: <CloseOutlined />,
301301
saveText: <CheckOutlined />,
302302
deleteText: false,
@@ -373,7 +373,9 @@ const schemaToDescriptionsItem = (
373373
) as ProFieldValueType)
374374
: (restItem.valueType as ProFieldValueType);
375375

376-
const isEditable = editableUtils?.isEditable(dataIndex || index);
376+
const isEditable = editableUtils?.isEditable(
377+
(dataIndex as React.Key) || index,
378+
);
377379

378380
const fieldMode = mode || isEditable ? 'edit' : 'read';
379381

@@ -418,7 +420,9 @@ const schemaToDescriptionsItem = (
418420
{showEditIcon && (
419421
<EditOutlined
420422
onClick={() => {
421-
editableUtils?.startEditable(dataIndex || index);
423+
editableUtils?.startEditable(
424+
(dataIndex as React.Key) || index,
425+
);
422426
}}
423427
/>
424428
)}
@@ -454,7 +458,9 @@ const schemaToDescriptionsItem = (
454458
{showEditIcon && valueType !== 'option' && (
455459
<EditOutlined
456460
onClick={() => {
457-
editableUtils?.startEditable(dataIndex || index);
461+
editableUtils?.startEditable(
462+
(dataIndex as React.Key) || index,
463+
);
458464
}}
459465
/>
460466
)}

0 commit comments

Comments
 (0)