Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(form): resolve shouldUpdate circular trigger problem #2948

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/form/FormItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ const FormItem = forwardRef<FormItemInstance, FormItemProps>((originalProps, ref
formMapRef.current.delete(name);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [name, formListName]);
}, [snakeName, formListName]);

useEffect(() => {
// value 变化通知 watch 事件
Expand All @@ -456,7 +456,7 @@ const FormItem = forwardRef<FormItemInstance, FormItemProps>((originalProps, ref

filterRules.length && validate('change');
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [formValue, name]);
}, [formValue, snakeName]);

// 暴露 ref 实例方法
const instance: FormItemInstance = {
Expand Down
5 changes: 3 additions & 2 deletions src/form/FormList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const FormList: React.FC<TdFormListProps> = (props) => {
formMapRef.current.delete(name);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [name]);
}, [snakeName]);

useEffect(() => {
[...formListMapRef.current.values()].forEach((formItemRef) => {
Expand Down Expand Up @@ -168,7 +168,8 @@ const FormList: React.FC<TdFormListProps> = (props) => {
if (data) callback(formItemRef, data);
});
});
}, [form, name, fields, formMapRef]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [form, snakeName, fields, formMapRef]);

useImperativeHandle(
formListRef,
Expand Down
Loading