Skip to content

Commit

Permalink
fix: list nest list
Browse files Browse the repository at this point in the history
  • Loading branch information
elevensky committed Apr 19, 2023
1 parent d1d5e2f commit 7b72c03
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/Field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,6 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F
function WrapperField<Values = any>({ name, ...restProps }: FieldProps<Values>) {
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';
Expand All @@ -650,7 +649,7 @@ function WrapperField<Values = any>({ name, ...restProps }: FieldProps<Values>)
<Field
key={key}
name={namePath}
isListField={mergedIsListField}
isListField={!!listContext}
{...restProps}
fieldContext={fieldContext}
/>
Expand Down
3 changes: 2 additions & 1 deletion src/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const List: React.FunctionComponent<ListProps> = ({
isListField,
}) => {
const context = React.useContext(FieldContext);
const wrapperListContext = React.useContext(ListContext);
const keyRef = React.useRef({
keys: [],
id: 0,
Expand Down Expand Up @@ -91,7 +92,7 @@ const List: React.FunctionComponent<ListProps> = ({
validateTrigger={validateTrigger}
initialValue={initialValue}
isList
isListField={isListField}
isListField={isListField ?? !!wrapperListContext}
>
{({ value = [], onChange }, meta) => {
const { getFieldValue } = context;
Expand Down

0 comments on commit 7b72c03

Please sign in to comment.