You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I realize React Hook Form is not designed around using onChange to fire off submits, but I am wondering if there is any way around this.
I've been requested to update multiple forms to autosave. I've been trying a few solutions and one thing I noticed is that if I try to send isDirty with the onChange event to skip saving if changes are reverted that it seems to lag a render cycle behind.
Is this something that could be solved somehow?
Should the submitHandler maybe (optionally) skip saving on pristine forms?
PS.
Full disclosure about the autosave requirements is not constant saving actually, since every update has to be audit logged. I'm thinking autosaving when routing away, closing browser, time interval perhaps. Using rxjs to manage the different events into a saving subscription.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I realize React Hook Form is not designed around using onChange to fire off submits, but I am wondering if there is any way around this.
I've been requested to update multiple forms to autosave. I've been trying a few solutions and one thing I noticed is that if I try to send isDirty with the onChange event to skip saving if changes are reverted that it seems to lag a render cycle behind.
To reproduce
https://codesandbox.io/s/rhf-onchange-fires-before-isdirty-validation-dd4whk
Check the checkbox and watch the console output.
Is this something that could be solved somehow?
Should the submitHandler maybe (optionally) skip saving on pristine forms?
PS.
Full disclosure about the autosave requirements is not constant saving actually, since every update has to be audit logged. I'm thinking autosaving when routing away, closing browser, time interval perhaps. Using rxjs to manage the different events into a saving subscription.
Beta Was this translation helpful? Give feedback.
All reactions