-
Notifications
You must be signed in to change notification settings - Fork 87
React 19 #865
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 19 #865
Conversation
Great! This would be much appreciated! 🙏 |
src/index.spec.js
Outdated
@@ -7,7 +7,7 @@ | |||
/* eslint-disable react/no-string-refs */ | |||
|
|||
import React, { Fragment, Component } from 'react'; | |||
import { createRenderer } from 'react-test-renderer/shallow'; | |||
import ShallowRenderer from 'react-shallow-renderer'; |
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.
this import crashes the test runner for some reason
update: it's because it depends on React internals and they've changed between majors. I wonder can the tests that depend on this be deleted. Not entirely sure what value they provide
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.
They cover some old pattern in class component. We could remove them and move on as shallow render is not a thing nowadays.
package.json
Outdated
"react": "^0.14.8 || ^15.0.1 || ^16.0.0 || ^17.0.1 || ^18.0.0 || ^19.0.0", | ||
"react-dom": "^0.14.8 || ^15.0.1 || ^16.0.0 || ^17.0.1 || ^18.0.0 || ^19.0.0", | ||
"react-is": "^18.0.0 || ^19.0.0" |
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.
Let's stop this madness and use this major version to only support react 19
Thanks for your PR @imjordanxd I will cleanup a little a release a new major soon. |
Overview
Adds support for React 19. I don't have a lot of time to add this and would appreciate any help 🙏
New context rendering
In React 19, we can render a context as follows:
The React Element produced by this is identical (as far as I can see!) to the React Element produced if we were to render:
Because of this change, serialisation is broken. We don't know how a context was rendered. Therefore, we can't produce a JSX string that accurately reflects the original JSX that was written. To support a wide range of React versions, we should serialise the new context rendering (
<Context>...</Context>
) as<Context.Provider>...</Context.Provider>
. This isn't exactly a 1:1 serialisation but React will still treat the JSX the same.Furthermore, the element type symbols have changed between React major versions. For example:
This means we cannot bundle
react-is
as a dependency and allow a wide range or React peer dependencies. We should expect consumers of this package to providereact-is
as a dependency which is aligned to their React version. This is a breaking change.