Skip to content

Commit

Permalink
chore: adding check by major version instead string
Browse files Browse the repository at this point in the history
  • Loading branch information
vctqs1 committed Feb 14, 2025
1 parent 67006f0 commit dca748f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import ReactDOM, { version as reactDomVersion } from 'react-dom';
// Uses the correct render API based on the available version of
// `react-dom`. This hack can be removed when support for older
// versions of React is removed.

const mainVersion = Number(reactDomVersion.split('.')[0]);
const canUseNewReactRootApi =
reactDomVersion &&
(reactDomVersion.startsWith('18') || reactDomVersion.startsWith('0.0.0'));
(mainVersion >= 18 || reactDomVersion.startsWith('0.0.0'));

export const renderElement = (node, outlet) => {
if (canUseNewReactRootApi) {
Expand Down

0 comments on commit dca748f

Please sign in to comment.