Skip to content

Commit 82f898e

Browse files
committed
fix: review
1 parent d40193a commit 82f898e

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/Field.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -627,17 +627,14 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F
627627
function WrapperField<Values = any>({ name, ...restProps }: FieldProps<Values>) {
628628
const fieldContext = React.useContext(FieldContext);
629629
const listContext = React.useContext(ListContext);
630+
const mergedIsListField = restProps.isListField || (!restProps.isList && !!listContext);
630631
const namePath = name !== undefined ? getNamePath(name) : undefined;
631632

632633
let key: string = 'keep';
633634
if (!restProps.isListField) {
634635
key = `_${(namePath || []).join('_')}`;
635636
}
636637

637-
if (restProps.isListField === undefined && !restProps.isList && listContext) {
638-
restProps.isListField = listContext.inList;
639-
}
640-
641638
// Warning if it's a directly list field.
642639
// We can still support multiple level field preserve.
643640
if (
@@ -649,7 +646,15 @@ function WrapperField<Values = any>({ name, ...restProps }: FieldProps<Values>)
649646
warning(false, '`preserve` should not apply on Form.List fields.');
650647
}
651648

652-
return <Field key={key} name={namePath} {...restProps} fieldContext={fieldContext} />;
649+
return (
650+
<Field
651+
key={key}
652+
name={namePath}
653+
isListField={mergedIsListField}
654+
{...restProps}
655+
fieldContext={fieldContext}
656+
/>
657+
);
653658
}
654659

655660
export default WrapperField;

src/List.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ const List: React.FunctionComponent<ListProps> = ({
6060
const pathName = namePath[len];
6161
return [keyManager.keys[pathName], namePath.slice(len + 1)];
6262
},
63-
inList: true,
6463
}),
6564
[prefixName],
6665
);

src/ListContext.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type { InternalNamePath } from './interface';
33

44
export interface ListContextProps {
55
getKey: (namePath: InternalNamePath) => [React.Key, InternalNamePath];
6-
inList: boolean;
76
}
87

98
const ListContext = React.createContext<ListContextProps | null>(null);

0 commit comments

Comments
 (0)