-
Notifications
You must be signed in to change notification settings - Fork 446
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
chore: upgrade test studios to react 19, remove next studios #8178
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/next@14.2.22, npm/react@19.0.0-rc-f994737d14-20240522 |
No changes to documentation |
Component Testing Report Updated Jan 6, 2025 1:05 PM (UTC) ✅ All Tests Passed -- expand for details
|
⚡️ Editor Performance ReportUpdated Mon, 06 Jan 2025 13:06:53 GMT
Detailed information🏠 Reference resultThe performance result of
🧪 Experiment resultThe performance result of this branch
📚 Glossary
|
3c46a12
to
90899ff
Compare
90899ff
to
4bf4355
Compare
4bf4355
to
f77be85
Compare
This is amazing! Very happy to also see the test-next-studio being removed. I agree with your assessment about using 19 as baseline. Thanks for laying out the pros&cons so clearly! I think it's super important that we also preserve the ability for devs to easily:
|
Description
Moves the test-studio, efps studio, and e2e studio, to react 19 at runtime.
Since test-studio is now on react 19 we no longer need the test-next-studio, so it's removed. After this merges I'll disconnect the vercel project from the repo so it stops adding failing checks to PRs, while historical deployments that documents our react 19 adoption and fixes are preserved and remain accessible.
Also thanks to being on 19 it's possible to run Million Lint without scoping it to exclude files that are transformed by React Compiler. The data collected is massive, and requires tons of RAM and CPU to profile. Thus it's available on a new command:
pnpm dev:million-lint-everything
. It has so much useful data:I couldn't help myself and fixed a few issues surfaced by it.
What to review
It seems like a massive effort to have the E2E testing suite run on both react 18 and 19, so I opted to run it on 19. If anyone has good ideas on how to make this happen without massive complexity or doubling CI wait time on PRs, feel welcome to contribute!
Should I add a
pnpm dev:react-18
command that lets us easily run the test studio on 18, in case react 18 regressions happen in the future? That feels like a good fast follow up to this one :)I've left vitest and playwright component test suites alone in this PR as it requires more planning in order to figure out how we can test on both react 19 and 18 in a good way, without introducing flake or doubling CI wait time.
Why it makes more sense to have 19 as the day-to-day baseline over 18
While we can setup E2E, integration tests, playwright, CLI tests, and such to run the same suites on both majors of React, we can't demand that of humans.
Time is finite, and if you give engineers the option to run both majors they'll pick one and rarely test the other major.
Currently the majority run 18, as that's what
pnpm dev
pulls up, and what E2E runs.pnpm dev:next-studio
grants access to the same test studio on 19, but has historically only been used when investigating bug reports of something not working on 19. If we were to add apnpm dev:react-19
command that runs on our vite setup instead of next.js, it's unlikely that'll be used outside of triaging bug reports from react 19 users.Story time on why it's called `test-next-studio` and why we it has had its own studio deployment.
It's called
test-next-studio
because those reports typically came from users on Next.js that embedded their studios (a common pattern for applications that has live preview, like presentation tool), where App Router basically have always used React 19 (or to be exact, canary versions of react) regardless of the react version installed in the userlandpackage.json
.Because of the popularity of embedding studios, every time a breaking change in React where introduced to its canary channel it affected our customers, and we had to fix them.
Testing the same version of React as the one Next.js is using isn't as simple as adopting canary release channels of react. Next.js has its own bundler (webpack and turbopack), we're using vite. Their setup includes SSR and hydration, our setup is just a client side rendered app.
It's far easier to just use Next.js and embed the studio directly and it gave us an easy way to test what ultimately became React 19 stable.
It's also worth mentioning that running
pnpm dev:next-studio
, and evenpnpm dev:turbo-studio
which is equivalent tonext dev --turbopack
, is much much slower than our vite based tooling so even if a Sanity engineer preferred testing on react 19 strict mode, it's not worth the much longer feedback loop and time spent waiting for the studio to hot reload.There are valid concerns for making 19 the new baseline, of course, as it introduces the risk of accidentally breaking studios on 18. Let's break it down in a pros/cons list:
useDeferredValue
has a second parameter on react 19 that sets the initial value on first render, and can be used to do less work on render on 19, while 18 works the same as before.React.use
and other APIs not available to 18. Most of it can be caught with tooling like ESLint a swell.ref
as a regular prop, removing requirement to useReact.forwardRef
, and accidental ref cleanup functions can be difficult to spot.useMemo
,useCallback
, are pure and free of side-effects that should be in auseEffect
. For example the Offscreen/Activity API lets components progressively render in the background.. While we're on 18 we're stuck with a StrictMode that isn't fully equipped to help us ensure the Studio won't break if these features are applied in custom userland code.TL;DR
With 19 as our baseline we still have a lot of tools in our disposal for preserving React 18 support, while delivering an excellent experience for our users on 19.
That's simply not the case if we remain on 18. Its Strict Mode doesn't help us make sure our code is safe and fully supports concurrent features on 18, nor on 19, and it forces us to remain reactive in our support for 19.
Testing
The E2E testing suite still pass, locally and on the CI. Same for the vercel deployment and manual testing.
Running
pnpm dev
,pnpm dev:million-lint
orpnpm dev:million-lint-everything
, should let you use http://localhost:3333 like before, but now on React 19 if you use react devtools to inspect the page.Notes for release
N/A