diff --git a/src/Field.tsx b/src/Field.tsx index 65189966..7a5eb868 100644 --- a/src/Field.tsx +++ b/src/Field.tsx @@ -627,6 +627,7 @@ class Field extends React.Component implements F function WrapperField({ name, ...restProps }: FieldProps) { const fieldContext = React.useContext(FieldContext); const listContext = React.useContext(ListContext); + const mergedIsListField = restProps.isListField || (!restProps.isList && !!listContext); const namePath = name !== undefined ? getNamePath(name) : undefined; let key: string = 'keep'; @@ -634,10 +635,6 @@ function WrapperField({ name, ...restProps }: FieldProps) key = `_${(namePath || []).join('_')}`; } - if (restProps.isListField === undefined && !restProps.isList && listContext) { - restProps.isListField = listContext.inList; - } - // Warning if it's a directly list field. // We can still support multiple level field preserve. if ( @@ -649,7 +646,15 @@ function WrapperField({ name, ...restProps }: FieldProps) warning(false, '`preserve` should not apply on Form.List fields.'); } - return ; + return ( + + ); } export default WrapperField; diff --git a/src/List.tsx b/src/List.tsx index 95f59f3c..64db2e20 100644 --- a/src/List.tsx +++ b/src/List.tsx @@ -64,7 +64,6 @@ const List: React.FunctionComponent = ({ const pathName = namePath[len]; return [keyManager.keys[pathName], namePath.slice(len + 1)]; }, - inList: true, }), [prefixName], ); diff --git a/src/ListContext.ts b/src/ListContext.ts index d5ef8f8c..cb5d0791 100644 --- a/src/ListContext.ts +++ b/src/ListContext.ts @@ -3,7 +3,6 @@ import type { InternalNamePath } from './interface'; export interface ListContextProps { getKey: (namePath: InternalNamePath) => [React.Key, InternalNamePath]; - inList: boolean; } const ListContext = React.createContext(null);