AutoSizer cannot be used as a JSX component typescript error
vitorhsb opened this issue · comments
Hi,
from version 1.0.10 and up I ended up having the following typescript error when using the AutoSizer component:
error TS2786: 'AutoSizer' cannot be used as a JSX component.
Its instance type 'AutoSizer' is not a valid JSX element.
The types returned by 'render()' are incompatible between these types.
Type 'ReactElement<any, string | JSXElementConstructor<any>>' is not assignable to type 'ReactNode'.
Property 'children' is missing in type 'ReactElement<any, string | JSXElementConstructor<any>>' but required in type 'ReactPortal'.
package.json context:
"@types/react": "17.0.2",
"@types/react-dom": "17.0.2",
"react": "17.0.2",
"react-dom": "17.0.2",
no additional types are included.
Property 'children' is missing in type 'ReactElement<any, string | JSXElementConstructor>' but required in type 'ReactPortal'.
Sounds like a specific issue with ReactPortal
?
Needs a repro.
I'm going to close this for now because it doesn't have a repro and I think it's an unnecessary constraint of ReactPortal
but if you update with a repro I'll be happy to take a look
I was trying to create a repro in codesandbox but didn't succeed at the moment.
I'm going to close this for now because it doesn't have a repro and I think it's an unnecessary constraint of ReactPortal but if you update with a repro I'll be happy to take a look
Actually I'm not using any ReactPortal in the application.
It must be related with the React types for version v17. I upgraded the @types/react to version 18 and the error went away.
Interesting.
Well thanks for the update!