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
Hi all, I am having a issue when using onChange and FormSpy, my scenario is that:
I use FormSpy and onChange to track the change of the form state, and I have another state outside of the form to do a dynamic validation based on the changed value, which works fine.
My issue here is that whenever I want to set a state (the validation state I mentioned above, or any other state that won't affect the form) in the onChange function, it will rerender the whole form, so that my cursor will loose focus and it will stop me from pressing tab to switch to another field anymore (as the form got rerendered).
I have also tried to use debug and validate, but it will end up with a infinite loop which seems not better than using onChange. And I believe that formOptions won't work outside of the form.
I was wondering if we have any solutions to prevent the form from rerendering in this kind of scenario, much appreciated! 🙏🙏🙏
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
-
Hi all, I am having a issue when using onChange and FormSpy, my scenario is that:
I use FormSpy and onChange to track the change of the form state, and I have another state outside of the form to do a dynamic validation based on the changed value, which works fine.
My issue here is that whenever I want to set a state (the validation state I mentioned above, or any other state that won't affect the form) in the onChange function, it will rerender the whole form, so that my cursor will loose focus and it will stop me from pressing tab to switch to another field anymore (as the form got rerendered).
I have also tried to use debug and validate, but it will end up with a infinite loop which seems not better than using onChange. And I believe that formOptions won't work outside of the form.
I was wondering if we have any solutions to prevent the form from rerendering in this kind of scenario, much appreciated! 🙏🙏🙏
Beta Was this translation helpful? Give feedback.
All reactions