feat: Add support for React 19 Canary#1294
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit b90d8cc:
|
| matrix: | ||
| node: [14, 16, 18] | ||
| react: [latest, canary, experimental] | ||
| react: ['18.x', latest, canary, experimental] |
There was a problem hiding this comment.
Added now so that we automatically continue testing React 18.x once React 19 is released.
| */ | ||
| hydrate?: boolean | ||
| /** | ||
| * Only works if used with React 18. |
There was a problem hiding this comment.
Should we also add this to our docs?
There was a problem hiding this comment.
| ) { | ||
| 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.
Perhaps this message could be more encouraging update, rather than encouraging tech debt?
There was a problem hiding this comment.
Good point. Do you have a suggestion for a better warning?
There was a problem hiding this comment.
My thoughts:
legacyRootis only relevant for earlier versions of React- If you're testing with React 19, there's a high chance you are also USING React 19, then it'd be best to just remove it
- If you're testing with React 19 but somehow you are NOT using React 19 yourself (?!), you may need help with migration.
Given that, my take:
Warning: legacyRoot is no longer supported in React 19. If your app runs React 19 or later, you should remove this flag. If your app runs React 18 or earlier, and you need help with upgrading your app, visit https://reactjs.org/link/switch-to-createroot.
There was a problem hiding this comment.
Makes sense: #1301. The link is not that applicable since you wouldn't need to change any callsites of render from RTL.
Closes #1270
We can release React 19 support as a SemVer MINOR. Even though
legacyRootis no longer supported, it's not really a RTL breaking change but a React breaking change that's handled in their SemVer MAJOR release. It would only be a RTL breaking change if React would be a direct dependency not a peer dependency as it is now.