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
Currently, there is no way to nicely handle state changes. This is useful for features like keeping a snapshot of the form state in local storage to protect against loosing form data on a page refresh before the form is saved. You could also use this to debounce the save / update after a period of inactivity, this would allow you to omit the page save and have an auto save feature.
As of now, the best way to do this is to create a component that does not render anything and uses the form context to subscribe to changes with useEffect
Allow the user to pass in an onChange function that will be called on state changes. The props passed in will be the contents of the context using the getContextValue this should give us enough info to get what we need done.
Problem to solve
Currently, there is no way to nicely handle state changes. This is useful for features like keeping a snapshot of the form state in local storage to protect against loosing form data on a page refresh before the form is saved. You could also use this to debounce the save / update after a period of inactivity, this would allow you to omit the page save and have an auto save feature.
As of now, the best way to do this is to create a component that does not render anything and uses the form context to subscribe to changes with
useEffect
Then you would have to render the component in the
Form
Proposal
Allow the user to pass in an
onChange
function that will be called on state changes. The props passed in will be the contents of the context using thegetContextValue
this should give us enough info to get what we need done.The form state subscription would then look like:
The auto save feature would then look something like:
The text was updated successfully, but these errors were encountered: