-
Notifications
You must be signed in to change notification settings - Fork 22
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
useFormPersist causes the component to rerender on every field change #33
Comments
Me too |
Yes, React.useEffect(() => {
const subscription = watch((value, { name, type }) =>
console.log(value, name, type)
)
return () => subscription.unsubscribe()
}, [watch]) |
Okay so I've run into this and was able to work through it by doing two things:
These two things fix the rendering issues because it causes that child component to re-render only instead of the main form component.
Then I just have this nested like so:
This will not work with this current version of PR where I made these changes if folks are interested: https://github.com/nucleuscloud/neosync/pull/1891/files |
I'm not sure if this is fixable (but I hope it is). After setting up
useFormPersist
using the repro steps below, my page whereuseForm
sits gets rerendered on every field change:By commenting out the
useFormPersist
command above the problem is resolved but obviously the functionality is gone.Motivation: Measured by Chrome DevTools / Performance tab, there is a 4-fold performance degradation with this command turned on (moving from 100ms to 400-500ms on my test case).
Suggestion: I think that if possible, the form should be persisted without causing the current element to rerender.
The text was updated successfully, but these errors were encountered: