Skip to content

Commit

Permalink
fix(react-render): fix React19 reactRender error (#3380)
Browse files Browse the repository at this point in the history
  • Loading branch information
HaixingOoO authored Feb 24, 2025
1 parent b323a77 commit af2d1a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/_util/react-render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// @ts-ignore
import type * as React from 'react';
import * as ReactDOM from 'react-dom';
import { createRoot as createRootClient } from 'react-dom/client';
import type { Root } from 'react-dom/client';

// Let compiler not to search module usage
Expand All @@ -16,13 +17,16 @@ const fullClone = {

type CreateRoot = (container: ContainerType) => Root;

// @ts-ignore
const { version, render: reactRender, unmountComponentAtNode } = fullClone;

let createRoot: CreateRoot;
try {
const mainVersion = Number((version || '').split('.')[0]);
if (mainVersion >= 18) {
if (mainVersion >= 18 && mainVersion < 19) {
({ createRoot } = fullClone);
} else if (mainVersion >= 19) {
createRoot = createRootClient;
}
} catch (e) {
// Do nothing;
Expand Down
2 changes: 1 addition & 1 deletion src/notification/NotificationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ const NotificationList = forwardRef<NotificationListInstance, NotificationListPr
return (
<NotificationComponent
ref={props.ref}
key={props.key}
{...props}
key={props.key}
onDurationEnd={() => {
remove(props.key);
onDurationEnd();
Expand Down

0 comments on commit af2d1a8

Please sign in to comment.