Skip to content

Commit

Permalink
fix(form): FormList same name will be cache problem (ant-design#4426)
Browse files Browse the repository at this point in the history
  • Loading branch information
rojer95 committed Jan 9, 2022
1 parent f6889df commit 15ab36f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/form/src/BaseForm/createField.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo } from 'react';
import React, { useMemo, useContext } from 'react';
import {
pickProFormItemProps,
omitUndefined,
Expand All @@ -11,6 +11,7 @@ import { stringify } from 'use-json-comparison';
import FieldContext from '../FieldContext';
import type { ExtendsProps, ProFormFieldItemProps, ProFormItemCreateConfig } from '../interface';
import ProFormItem from '../components/FormItem';
import { FieldContext as RcFieldContext } from 'rc-field-form';

export const TYPE = Symbol('ProFormComponent');

Expand Down Expand Up @@ -127,10 +128,13 @@ function createField<P extends ProFormFieldItemProps = any>(

const ignoreWidthValueType = useMemo(() => ['switch', 'radioButton', 'radio', 'rate'], []);

const { prefixName } = useContext(RcFieldContext);
const proFieldKey = useMemo(() => {
return otherProps?.name && `form-field-${otherProps.name}`;
let name = otherProps?.name;
if (Array.isArray(prefixName) && name) name = `${prefixName.join('.')}.${name}`;
return name && `form-field-${name}`;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [stringify(otherProps?.name)]);
}, [stringify(otherProps?.name), prefixName]);

const realFieldPropsStyle = useMemo(
() => ({
Expand Down

0 comments on commit 15ab36f

Please sign in to comment.