-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: Add support for React 19 Canary #1294
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,6 +207,14 @@ function render( | |
wrapper, | ||
} = {}, | ||
) { | ||
if (legacyRoot && typeof ReactDOM.render !== 'function') { | ||
const error = new Error( | ||
'`legacyRoot: true` is not supported in this version of React. Please use React 18 instead.', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps this message could be more encouraging update, rather than encouraging tech debt? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. Do you have a suggestion for a better warning? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My thoughts:
Given that, my take:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense: #1301. The link is not that applicable since you wouldn't need to change any callsites of |
||
) | ||
Error.captureStackTrace(error, render) | ||
throw error | ||
} | ||
|
||
if (!baseElement) { | ||
// default to document.body instead of documentElement to avoid output of potentially-large | ||
// head elements (such as JSS style blocks) in debug output | ||
|
@@ -263,6 +271,15 @@ function cleanup() { | |
|
||
function renderHook(renderCallback, options = {}) { | ||
const {initialProps, ...renderOptions} = options | ||
|
||
if (renderOptions.legacyRoot && typeof ReactDOM.render !== 'function') { | ||
const error = new Error( | ||
'`legacyRoot: true` is not supported in this version of React. Please use React 18 instead.', | ||
) | ||
Error.captureStackTrace(error, renderHook) | ||
throw error | ||
} | ||
|
||
const result = React.createRef() | ||
|
||
function TestComponent({renderCallbackProps}) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,6 +73,7 @@ export interface RenderOptions< | |
*/ | ||
hydrate?: boolean | ||
/** | ||
* Only works if used with React 18. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also add this to our docs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
* Set to `true` if you want to force synchronous `ReactDOM.render`. | ||
* Otherwise `render` will default to concurrent React if available. | ||
*/ | ||
|
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.
Added now so that we automatically continue testing React 18.x once React 19 is released.