React 18 typescript problem
See original GitHub issueReact has recently released version 18 and along with it also a tightened type checking. This results in many error related to the children property on components.
TS2769: No overload matches this call.
Overload 1 of 2, '(props: ReflexElementProps | Readonly<ReflexElementProps>): ReflexElement', gave the following error.
<e> Type '{ children: never[]; key: string; direction: -1; ref: MutableRefObject<ReflexElement | null>; className: any; size: number; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<ReflexElement> & Readonly<ReflexElementProps>'.
<e> Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<ReflexElement> & Readonly<ReflexElementProps>'.
<e> Overload 2 of 2, '(props: ReflexElementProps, context: any): ReflexElement', gave the following error.
<e> Type '{ children: never[]; key: string; direction: -1; ref: MutableRefObject<ReflexElement | null>; className: any; size: number; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<ReflexElement> & Readonly<ReflexElementProps>'.
<e> Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<ReflexElement> & Readonly<ReflexElementProps>'.
TS2769: No overload matches this call.
<e> Overload 1 of 2, '(props: ReflexContainerProps | Readonly<ReflexContainerProps>): ReflexContainer', gave the following error.
<e> Type '{ children: Element[]; key: string; orientation: "horizontal"; style: { height: number; }; windowResizeAware: true; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<ReflexContainer> & Readonly<ReflexContainerProps>'.
<e> Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<ReflexContainer> & Readonly<ReflexContainerProps>'.
<e> Overload 2 of 2, '(props: ReflexContainerProps, context: any): ReflexContainer', gave the following error.
<e> Type '{ children: Element[]; key: string; orientation: "horizontal"; style: { height: number; }; windowResizeAware: true; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<ReflexContainer> & Readonly<ReflexContainerProps>'.
<e> Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<ReflexContainer> & Readonly<ReflexContainerProps>'.
I’m not a typescript expert but seems to me like children
now has to be explicitly defined as a prop type.
Issue Analytics
- State:
- Created a year ago
- Reactions:10
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Bug: React 18 types broken since the type release a view ...
I want to reiterate that using TypeScript is a choice. You don't have to use React with TypeScript. If you choose to use...
Read more >How to use TypeScript with React 18 alpha
This is the TypeScript compiler complaining that it doesn't know anything about ReactDOM.createRoot . This is because the type definitions that ...
Read more >Upgrading to react@18 and react-dom@18 fails
So, I went back and created a brand new app with npx create-react-app react18 --template typescript . It now wants react@18 and react-dom@18...
Read more >React
There is an automated migration script that you can use to update your application code. It helps fix the most common issues when...
Read more >Upgrade to react 18 — Issues and resolution - Dev Genius
Made React.StrictMode component a child/descendent of Provider component in my src/index.js file. There are some significant updates to strict mode in React 18...
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 FreeTop 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
Top GitHub Comments
I will take a look at this asap …
@akphi check version
4.0.8
please. ts definition should now be up-to-date. @AnabelSalomone,renderOnResizeRate
was removed from the code as it caused problems, sorry for the bad news. I would need to look into it again at some point. If you have troubles with resizing, log an issue pls.