Skip to content
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

Don't expose internal errors reference in handleSubmit #7718

Conversation

tiii
Copy link
Contributor

@tiii tiii commented Feb 2, 2022

Fixes #7717

_formState.errors are cloned before passing them on to onInvalid handler.

This requires a change in the cloneObject method:

On the web context we have lots of references on a HTMLElement which would already slow the method down. On top of that, a HTMLInputElement has a reference to the form, which itself references it's inputs again, causing an infinite loop.

Because of that we now ignore HTMLElements on the web and accordingly Components when using react-native and instead pass those on without cloning.

@tiii tiii force-pushed the dont-expose-internal-state-in-handleSubmit-onInvalid branch 3 times, most recently from 0b278d5 to 2ec55c6 Compare February 3, 2022 10:29
@tiii tiii force-pushed the dont-expose-internal-state-in-handleSubmit-onInvalid branch from 2ec55c6 to 6006c2f Compare February 3, 2022 10:44
@bluebill1049
Copy link
Member

thank you again for your contribution.

@bluebill1049 bluebill1049 merged commit 28419cf into react-hook-form:master Feb 3, 2022
@tiii tiii deleted the dont-expose-internal-state-in-handleSubmit-onInvalid branch February 3, 2022 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

issue: [handleSubmit] exposes internal errors references in onInvalid callback
2 participants