issue: API Breakage on FieldErrors
See original GitHub issueVersion Number
7.33.1
Codesandbox/Expo snack
Compile error, so no code sandbox is available.
Steps to reproduce
I am building out a set of Typescript React components (based on react-hook-form and react-bootstrap). The source code for this library is at:
https://github.com/craigmcc/shared-react
With react-hook-form 7.30.0, everything was fine. With react-hook-form 7.33.1, I get compile errors trying to build the library (see the “Relevant Log Output” section below).
It looks like changes to the FieldErrors definition is what is triggering this.
TO REPRODUCE:
- Download the GItHub module mentioned above.
- Run “npm install” to install the listed dependencies.
- Run “npm install react-hook-form@7.33.1” to get the version that causes the problem.
- Run “npm build” and see the compile errors (shown in the “Relevant log output” section below).
Expected behaviour
No compile errors.
What browsers are you seeing the problem on?
Chrome
Relevant log output
COMPILE OUTPUT:
==============
MacBook-Pro:shared-react craigmcc$ npm run build
> @craigmcc/shared-react@1.2.1 build
> tsc -p .
src/SelectField/SelectField.tsx:71:17 - error TS2322: Type 'Merge<FieldError, FieldErrorsImpl<DeepRequired<any>>> | undefined' is not assignable to type 'ReactNode'.
Type 'Merge<FieldError, FieldErrorsImpl<DeepRequired<any>>>' is not assignable to type 'ReactNode'.
Type 'Merge<FieldError, FieldErrorsImpl<DeepRequired<any>>>' is missing the following properties from type 'ReactPortal': key, children, type, props
71 {props.errors[props.name]?.message}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/react/index.d.ts:1374:9
1374 children?: ReactNode | undefined;
~~~~~~~~
The expected type comes from property 'children' which is declared here on type 'IntrinsicAttributes & Omit<Pick<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof HTMLAttributes<...>> & { ...; }, BsPrefixProps<...> & FeedbackProps> & BsPrefixProps<...> & FeedbackProps & { ...; }'
src/TextField/TextField.tsx:66:17 - error TS2322: Type 'Merge<FieldError, FieldErrorsImpl<DeepRequired<any>>> | undefined' is not assignable to type 'ReactNode'.
66 {props.errors[props.name]?.message}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/react/index.d.ts:1374:9
1374 children?: ReactNode | undefined;
~~~~~~~~
The expected type comes from property 'children' which is declared here on type 'IntrinsicAttributes & Omit<Pick<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof HTMLAttributes<...>> & { ...; }, BsPrefixProps<...> & FeedbackProps> & BsPrefixProps<...> & FeedbackProps & { ...; }'
Found 2 errors in 2 files.
Errors Files
1 src/SelectField/SelectField.tsx:71
1 src/TextField/TextField.tsx:66
Code of Conduct
- I agree to follow this project’s Code of Conduct
Issue Analytics
- State:
- Created a year ago
- Reactions:4
- Comments:11 (3 by maintainers)
Top Results From Across the Web
JSON API response line breaks - java - Stack Overflow
The issue I am facing is the text in the error response does not match the intended design i.e. I want the message...
Read more >API 2012_2 custom field errors — Oracle NetSuite Support Community
all of a sudden, with no changes by me we started getting errors that a custom field is read only and cannot be...
Read more >Pulumi/Terraform Alerts API regression
This morning we suddenly started seeing “Cannot query field “slideBy” on type “AlertsNrqlConditionSignal”.” when trying to update our alerts.
Read more >Ensuring code changes do not break Microservice REST API, during ...
Our objective is to shift the microservice API tests left, and execute them as a part of PR validation itself, using Azure Pipelines....
Read more >FormError lack of compatibility default api validation errors - Get ...
First issue I encountered with this structure is that when passing the ... lists the field errors in a list and prefixes the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Codesandbox link: https://codesandbox.io/s/goofy-fast-vdssvf
Although the app runs in the sandbox (it fails for me locally), if you open src/TextField.tsx and src/MyForm.tsx you will see the highlighted errors.
Change the react-hook-form dependency to 7.32 and it makes those errors go away.
happens only with useFormContext, not with useForm –> https://codesandbox.io/s/sad-allen-tgj0ho?file=/src/FormField.tsx