-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix(form): stabilize ProForm/BaseForm renders and FormItem memoization #9605
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -69,20 +69,18 @@ const WithValueFomFiledProps: React.FC< | |||||
| ); | ||||||
| }); | ||||||
|
|
||||||
| const childFieldProps = React.isValidElement(filedChildren) | ||||||
| ? (filedChildren.props as Record<string, any>)?.fieldProps | ||||||
| : undefined; | ||||||
|
|
||||||
| const omitOnBlurAndOnChangeProps = useDeepCompareMemo( | ||||||
| () => | ||||||
| omit( | ||||||
| // @ts-ignore | ||||||
| filedChildren?.props?.fieldProps || {}, | ||||||
| ['onBlur', 'onChange'], | ||||||
| ), | ||||||
| [ | ||||||
| omit( | ||||||
| // @ts-ignore | ||||||
| filedChildren?.props?.fieldProps || {}, | ||||||
| childFieldProps || {}, | ||||||
| ['onBlur', 'onChange'], | ||||||
| ), | ||||||
| ], | ||||||
| [childFieldProps], | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The change to the dependency array of
Suggested change
|
||||||
| ); | ||||||
| const propsValuePropName = formFieldProps[valuePropName]; | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding
formRefto the dependency array ofuseMemois unnecessary and potentially misleading.formRefis a ref object created viauseRefwithin the component, so its reference is stable and will not trigger a re-computation of the memoized value. Furthermore, adding a ref object to dependencies does not solve "stale snapshot" issues becauseuseMemodoes not track changes to the.currentproperty. If the intent is to ensure the latest form instance is used, accessingformRef.currentinside the factory is sufficient, but it won't trigger updates if the ref is updated after the initial render.