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

close #8653 when useFormContext provide no generic for type check #8654

Merged
merged 2 commits into from Jul 8, 2022

Conversation

bluebill1049
Copy link
Member

@bluebill1049 bluebill1049 commented Jul 8, 2022

ref: https://codesandbox.io/s/react-hook-form-chakra-ui-forked-0kcquv?file=/src/App.tsx

related: #8652 #8619

Prevent compile error when user not provide generic for context

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 8, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 363e6ea:

Sandbox Source
React Hook Form V7 (JS) Template Configuration
React Hook Form V7 (TS) Template Configuration
react-hook-form-chakra-ui (forked) PR

@github-actions
Copy link
Contributor

github-actions bot commented Jul 8, 2022

Size Change: 0 B

Total Size: 17.6 kB

ℹ️ View Unchanged
Filename Size
dist/index.cjs.js 8.75 kB
dist/index.umd.js 8.87 kB

compressed-size-action

@bluebill1049 bluebill1049 marked this pull request as ready for review July 8, 2022 23:32
@bluebill1049 bluebill1049 merged commit 2e0c3f8 into master Jul 8, 2022
bluebill1049 added a commit that referenced this pull request Jul 9, 2022
bluebill1049 added a commit that referenced this pull request Jul 10, 2022
…8654)

* close #8653 when useFormContext provide no generic for type check

* update api contract
bluebill1049 added a commit that referenced this pull request Jul 10, 2022
bluebill1049 added a commit that referenced this pull request Jul 13, 2022
* V8: feature: useFieldArray rules props (#8102)

* useFieldArray rules prop

* remove required prop

* combine logic within validateField

* remove logic

* update unset method to support root node in array

* update api extrator

* update type

* update useEffect validation logic

* update api extrator

* fix submit field array error

* extract logic into its own function for update root error object

* 8.0.0-alpha.3

* update with unit tests coverage for rules validate, minLength and maxLength

* include support for required prop for consitent API and test coverage

* update API

* save some bytes

* upgrade to react 18

* Revert "upgrade to react 18"

This reverts commit d1c3bf7.

* update react

* fix cypress test

* remove render count

* udpate package and include test coverage for nested field array

* fix unit and cypress tests

* update lock file

* revert package

* avoid react native breaking change and fix test

* fix test and type error

* 🚔 close #8653 when useFormContext provide no generic for type check (#8654)

* close #8653 when useFormContext provide no generic for type check

* update api contract

* 🛰 useFormContext include type tests (#8656)

* Revert "🚔 close #8653 when useFormContext provide no generic for type check (#8654)"

This reverts commit 2e0c3f8.

* Revert "🛰 useFormContext include type tests (#8656)"

This reverts commit 34af5b3.

* 🥼 update changelog related to #8653

* 7.34.0-next.0

* check validation required for field array if not array or empty length

* include unit tests coverage for validate fields for array fields

* update api extrator
@bluebill1049 bluebill1049 deleted the close-8653 branch July 13, 2022 10:55
@niemyjski
Copy link

This is still blocking me I'm passing errors in as an object: errors: FieldErrors; and binding on it: {errors.name?.message}. The object looks like

{
      name: {
        message: "Please specify a valid name."
      }
}

This is leading me to get errors like: Type 'string' is not assignable to type 'FieldError | Merge<FieldError, FieldErrorsImpl<any>> | undefined'.

or

No overload matches this call.
  Overload 1 of 2, '(props: { component: ElementType<any>; } & { children?: ReactNode; classes?: Partial<FormHelperTextClasses>; disabled?: boolean; ... 6 more ...; variant?: "filled" | ... 1 more ... | "outlined"; } & CommonProps & Omit<...>): Element', gave the following error.
    Type 'string | FieldError | Merge<FieldError, FieldErrorsImpl<any>> | undefined' is not assignable to type 'ReactNode'.
      Type 'FieldError' is not assignable to type 'ReactNode'.
        Type 'FieldError' is missing the following properties from type 'ReactPortal': key, children, props
  Overload 2 of 2, '(props: DefaultComponentProps<FormHelperTextTypeMap<{}, "p">>): Element', gave the following error.
    Type 'string | FieldError | Merge<FieldError, FieldErrorsImpl<any>> | undefined' is not assignable to type 'ReactNode'.ts(2769)

@DanielBlytheCTO
Copy link

I'm getting very similar error, @niemyjski did you manage to solve this? Or at least a workaround?

@niemyjski
Copy link

No, I ended up pinned to an older version :(

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.

None yet

3 participants