-
Notifications
You must be signed in to change notification settings - Fork 649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
react-transition-group demo using TypeScript no longer works when upgrading to @types/react & @types/react-dom v18 #813
Comments
v17 also doesn't work for that matter. I get the exact same error |
Bear with me as I handwave my shallow knowledge of yarn dependency resolution, transitive dependencies and hoisting right now... The react-transition-group's yarn.lock file right now specifies But, it's possible that the same set of dependency upgrades that RTG is doing to get up to react@18 and leaving behind a Might want to check your lock file and see if you have anything that says: " and then: " Meanwhile, your package.json file could be saying Then you may end up with a package manager like yarn putting an "unhoisted" older version into the react-transition-group transitive node_modules dir. If that's the problem, I'm not sure what the proper solution is, though. |
Maybe some form of this: yarnpkg/yarn#1785 Which seems to have this as a workaround: https://classic.yarnpkg.com/lang/en/docs/selective-version-resolutions/ ... if you're using yarn. |
Also possibly related: DefinitelyTyped/DefinitelyTyped#59765 and reduxjs/react-redux#1886. The I'm using yarn so I am resolving this issue by using "overrides": {
"@types/react": "17.0.43",
"@types/react-dom": "17.0.14"
}, Once @types/react-transition-group updates its dependency of @types/react and @types/react-dom to support v18, I think I can get rid of the |
I no longer get the error: Also, I am no longer resolving this issue by using |
The error BTW, I'm also getting this However, I was able to fix the Now, I can now use the latest react v18, react-dom v18, @types/react v18, and @types/react-dom v18 and no longer get the TS lint error on my react-transition-group demo using TypeScript. Here is the updated Fade.tsx: import { PropsWithChildren, useRef } from 'react';
import {
TransitionProps,
TransitionStatus,
} from 'react-transition-group/Transition';
import { Transition } from 'react-transition-group';
import CSS from 'csstype';
const duration = 300;
const defaultStyle = {
transition: `opacity ${duration}ms ease-in-out`,
opacity: 0,
};
const transitionStyles: Partial<Record<TransitionStatus, CSS.Properties>> = {
entering: { opacity: 1 },
entered: { opacity: 1 },
exiting: { opacity: 0 },
exited: { opacity: 0 },
};
function Fade({
in: inProp,
children,
}: PropsWithChildren<TransitionProps<HTMLDivElement>>) {
const nodeRef = useRef<HTMLDivElement>(null);
return (
<Transition nodeRef={nodeRef} in={inProp} timeout={duration}>
{(state) => (
<div
style={{
...defaultStyle,
...transitionStyles[state],
}}
>
{children}
</div>
)}
</Transition>
);
}
export default Fade; |
Closing this issue since I am no longer getting TS lint errors on my react-transition-group demo using Typescript, |
For those who are running projects where it's not appropriate to delete your Override @types/react to 18.0.0 your package.json
.. replace the ** and do a bit of trial and error if you want to fix the resolution to the react-transition-group packages. Run
|
I am using react v18, react-dom v18, react-transition-group v4.4.2, @types/react v18, @types/react-doom v18, and @types/react-transition-group v4.4.4
Before upgrading @types/react from v17.0.43 to v.18 and @types/react-dom from v17.0.14 to v.18, my react-transition-demo using TypeScript had no lint errors and worked fine.
After upgrading @types/react & @types/react-dom to v18, I get 2 lint errors:
I believe the issue is that @types/react-transition-group no longer works with @types/react v18 and @types/react-dom v18.
I expected no TypeScript lint errors after upgrading @types/react & @types/react-dom to v18.
I'll won't be able to provide a CodeSandbox demo reproducing the bug until later this evening. Until then, here is my
SimpleFadeDemo.tsx
react component that has TS lint errors after upgrading @types/react from v17.0.43 to v.18 and @types/react-dom from v17.0.14 to v.18:SimpleFadeDemo.tsx:
The text was updated successfully, but these errors were encountered: