-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[core] Bump React to 19 #42824
base: master
Are you sure you want to change the base?
[core] Bump React to 19 #42824
Conversation
@aarongarciah, we're working on the Emotion type fixes alongside the Emotion maintainers: emotion-js/emotion#3206 The next issue I'm facing is with the following packages:
Neither of these are up to date, and I don't think it's worth it for us to to try and update them like we did with Emotion:
So I think we should deprecate |
@DiegoAndai I think this makes sense.
Can you expand a bit? I assume you're talking about the top level package.json resolutions. Can we add a |
Netlify deploy preview
AvatarGroup: parsed: -1.22% 😍, gzip: -1.09% 😍 Bundle size reportDetails of bundle changes (Toolpad) |
Hey @Janpot @michaldudak, I need your help with this. Could you check the branch and see if you can figure it out? We have two packages which are not compatible with React 19 types:
Important note: Focus only on the Here are the errors I'm getting:
|
Also, I would expect this line to exclude the |
Going to sleep now, so can't help much, but got some points that might help you:
probably
Resolutions is for "pnpm": {
"overrides": {
"@types/react": "18.3.3",
"@types/react-dom": "18.3.0"
}
}, |
@JCQuintas
|
oops didn't know that. 🙃 |
Yes, |
As far as I know there is no other way around this right now, since you can't select which libs to skip in typescript. Since we are already doing the "resolutions" change, that is a "trust me" moment. Sure the lib check might help catching so issues, but if the types are different, then you will definitely get an error with the only opt out I know being |
@@ -267,7 +267,7 @@ export function useSlider(parameters: UseSliderParameters): UseSliderReturnValue | |||
|
|||
const [focusedThumbIndex, setFocusedThumbIndex] = React.useState(-1); | |||
|
|||
const sliderRef = React.useRef<HTMLSpanElement>(); | |||
const sliderRef = React.useRef<HTMLSpanElement>(undefined); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be?
const sliderRef = React.useRef<HTMLSpanElement>(undefined); | |
const sliderRef = React.useRef<HTMLSpanElement>(null); |
It should be an immutable ref here. It looks like I have missed this one in #38762. We could make a PR just for it.
I dove a bit into this in mui/mui-x#11847.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, ok, it's changing: DefinitelyTyped/DefinitelyTyped#64896, so
const sliderRef = React.useRef<HTMLSpanElement>(undefined); | |
const sliderRef = React.useRef<HTMLSpanElement | null>(null); |
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think | null
is the correct approach, yeah #42881 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, then +1 to udpate all the codebase with this. We don't have to correlate it with React 19..it seems that it would work with all versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For posterity, in React 19:
React.useRef
requires an initial value. There's no need to do| null
when the initial value isnull
(same forundefined
). You can still do it if you want to be more explicit. It goes like this (pseudo-code):const ref = React.useRef<T>(null)
->ref
isT | null
const ref = React.useRef<T>(undefined)
->ref
isT | undefined
const ref = React.useRef<T>(T)
->ref
isT
React.MutableRefObject
has been deprecated.React.RefObject
is used for all cases now, and it's always mutable. UnlikeReact.Ref
, we need to explicitly make the ref object nullable:React.RefObject<T | null>
.
(more info in the React 19 types PR)
I'll try to take a look at this over the week, but what I can already say about resolutions is that I don't think of it as a tool we can use to solve this problem. As far as I'm aware, as a package author, you can't enforce how your transitive dependencies are resolved by the consumers of your package. So we'd fix the problem in our repo, but I believe our users would still have it. I think we shouldn't use resolutions/overrides, unless it's scoped to the docs workspace. edit:
Not 100% clear to me yet what exactly is going on here. It's referencing |
Thanks for taking a look @Janpot
With this, do you mean that we shouldn't have I tried the patch approach but I still get the same errors 😓 The issue here is that I'm not able to figure out how to make the pnpm workspace like this:
Do you see a way of making it work like that? |
This feels a bit too bold. I could see a lot of people using styled-components and not care about types, as well as upgrading Material UI to v6 without upgrading React or Next.js. If we can ignore the types for those packages, I think it would be good enough. |
I'm taking a closer look today
Correct, in fact we shouldn't have
|
I opened an issue in the styled-components repo regarding the I'll try to open a PR with a potential fix. |
@Janpot I wonder why. I know it's not ideal, but what if React 19 releases before styled-components fixes the issue? Would you be against using the patch in that situation as well? |
Because end-users wouldn't get this patch, so they'd still see the typing errors. But yeah, we can probably relax as this is only a dependency of |
btw, for us I would consider the same thing, instead of the patch, enable |
@Janpot should I enable |
If that works. The advantage would be that we isolate the hack a bit more to |
It's working locally 👍🏼 I'll need to check the CI builds "killed" signal issue, but it should also work in CI. |
Given the amount of dependency changes, When the time comes to merge this, we can change all test containers to |
Part of #42381
This PR serves as a sandbox to check how many issues we have left to solve to support React 19.