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

Fix data param in handleSubmit when TTransformedValues is a union type #11420

Merged

Conversation

Ar4ys
Copy link
Contributor

@Ar4ys Ar4ys commented Jan 20, 2024

Proposed Changes

Replaces current UseFormHandleSubmit implementation with the one that relies on default values in generics. For more info see this comment in original issue: #11414 (comment)

Fixes #11414

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes

Copy link

codesandbox bot commented Jan 20, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@Ar4ys Ar4ys force-pushed the fix-ttransformedvalues-with-union branch from 041b367 to 2f004e3 Compare January 20, 2024 13:19
@@ -769,6 +765,7 @@ export type BatchFieldArrayUpdate = <
export type Control<
TFieldValues extends FieldValues = FieldValues,
TContext = any,
TTransformedValues extends FieldValues = TFieldValues,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite adding new generic to Control, this should not be a breaking change, because TTransformedValues has a default value of TFieldValues, so previous code that only specified TFieldValues should still work as expected.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 👍

Copy link
Member

@bluebill1049 bluebill1049 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bluebill1049 bluebill1049 merged commit 6fee03c into react-hook-form:master Jan 22, 2024
7 checks passed
bluebill1049 added a commit that referenced this pull request Feb 16, 2024
rafaelcalhau pushed a commit to rafaelcalhau/react-hook-form that referenced this pull request May 5, 2024
…ype (react-hook-form#11420)

* Rewritten UseFormHandleSubmit to use default values in generics

* Updated api-extractor report

---------

Co-authored-by: Beier (Bill) <bluebill1049@hotmail.com>
rafaelcalhau pushed a commit to rafaelcalhau/react-hook-form that referenced this pull request May 5, 2024
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: data param in onValid in handleSubmit infers as any when TTransformedValues is a union type
2 participants