Skip to content

Commit

Permalink
feat(form): optimize setField same not rerender (#3302)
Browse files Browse the repository at this point in the history
  • Loading branch information
HaixingOoO authored Dec 26, 2024
1 parent 9b74c84 commit 4c45f9d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/form/FormItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
CloseCircleFilledIcon as TdCloseCircleFilledIcon,
ErrorCircleFilledIcon as TdErrorCircleFilledIcon,
} from 'tdesign-icons-react';
import isEqual from 'lodash/isEqual';
import { calcFieldValue } from './utils';
import useConfig from '../hooks/useConfig';
import useGlobalIcon from '../hooks/useGlobalIcon';
Expand Down Expand Up @@ -165,7 +166,9 @@ const FormItem = forwardRef<FormItemInstance, FormItemProps>((originalProps, ref
isUpdatedRef.current = true;
shouldValidate.current = validate;
valueRef.current = newVal;
setFormValue(newVal);
if (!isEqual(formValue, newVal)) {
setFormValue(newVal);
}
};

// 初始化 rules,最终以 formItem 上优先级最高
Expand Down

0 comments on commit 4c45f9d

Please sign in to comment.