reactjs / react-transition-group

An easy way to perform animations when a React component enters or leaves the DOM
https://reactcommunity.org/react-transition-group/
Other
10.1k stars 652 forks source link

'ReactCSSTransition' cannot be used as a JSX component. Its instance type 'CSSTransition<HTMLElement | undefined>' is not a valid JSX element. #855

Open Khoby-790 opened 1 year ago

Khoby-790 commented 1 year ago

What is the current behavior? 'ReactCSSTransition' cannot be used as a JSX component. Its instance type 'CSSTransition<HTMLElement | undefined>' is not a valid JSX element.

What is the expected behavior? It should be able to resolve with react 18

i updated to react 18 and my transition is breaking

Could you provide a CodeSandbox demo reproducing the bug? Its instance type 'Provider' is not a valid JSX element. The types returned by 'render()' are incompatible between these types. Type 'import("/Users/khoby/Kodes/Livoh/weba-app/node_modules/@types/testing-library__react/node_modules/@types/react/index").ReactNode' is not assignable to type 'React.ReactNode'.

Art1xFX commented 1 year ago

Had the same problem. My application has the following dependencies:

Package Version
react ^18.2.0
react-dom ^18.2.0
react-scripts ^5.0.1
react-transition-group ^4.4.2
@types/node ^18.7.18
@types/react ^18.0.0
@types/react-dom ^18.0.0
@types/react-transition-group ^4.4.4
typescript ^4.8.3

I've tried to upgrade versions of @types/* packages using yarn specifying the latest versions of ones:

yarn upgrade react@^18.2.0 react-dom@^18.2.0 @types/react@^18.0.21 @types/react-dom@^18.0.6 react-transition-group@^4.4.5 @types/react-transition-group@^4.4.5

But it did not work. So, after that i tried to update all packages with yarn upgrade command without any parameter:

yarn upgrade

It helped me. May be it will help you too

ltsfran commented 1 year ago

I have the same problem, I had to add resolutions property in my package.json with 17.0.38 version of @types/react

angelikatyborska commented 1 year ago

I experienced the same issue. Messing around with dependency versions didn't help me. Turns out in my case the issue was caused by conflicting type definitions for JSX.Element between React and Vue, see: https://github.com/vuejs/core/issues/1033

I forced my app to compile by following the recommendation from https://github.com/vuejs/core/issues/1033#issuecomment-1176412645 and applying a local patch to Vue that removes the conflicting type (thankfully I only needed TypeScript to work with React in my project).

mmoreno2-rbi commented 9 months ago

I'm having the same issue after running yarn upgrade. I'm using react 18, and adding resolutions property didn't work

dzmitryshkindzer commented 6 months ago

+1

axe312ger commented 6 months ago

Good old npx yarn-deduplicate && yarn helped me.

Otherwise.. delete your lock file and do a fresh install :)

m-podlesny commented 1 month ago

yarn dedupe for v3+