question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React 18 typescript problem

See original GitHub issue

React 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:closed
  • Created a year ago
  • Reactions:10
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
leefsmpcommented, Apr 28, 2022

I will take a look at this asap …

3reactions
leefsmpcommented, May 13, 2022

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found