Prevent form rerendering when change a state in onChange #1465
Unanswered
fdx-han-xiao
asked this question in
Need help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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