From c88b4cb7845a90a36fb1b1d39b802aeb6ab5354b Mon Sep 17 00:00:00 2001 From: "Lu, Jun" Date: Fri, 1 Nov 2024 13:20:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E5=85=BC=E5=AE=B9=E5=9C=A8=20React?= =?UTF-8?q?=2019=20=E7=8E=AF=E5=A2=83=E4=B8=8B=E7=9A=84=20Toast=20?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Close #6635 --- src/utils/render.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/render.ts b/src/utils/render.ts index d3c8206e92..9dfd26edbc 100644 --- a/src/utils/render.ts +++ b/src/utils/render.ts @@ -1,6 +1,6 @@ import type { ReactElement } from 'react' import * as ReactDOM from 'react-dom' -import type { Root } from 'react-dom/client' +import { type Root, createRoot as createClientRoot } from 'react-dom/client' // 移植自rc-util: https://github.com/react-component/util/blob/master/src/React/render.ts @@ -21,9 +21,9 @@ const { version, render: reactRender, unmountComponentAtNode } = fullClone let createRoot: CreateRoot try { const mainVersion = Number((version || '').split('.')[0]) - if (mainVersion >= 18 && fullClone.createRoot) { - // eslint-disable-next-line @typescript-eslint/no-var-requires - createRoot = fullClone.createRoot + const createReactRoot = createClientRoot || fullClone.createRoot + if (mainVersion >= 18 && createReactRoot) { + createRoot = createReactRoot } } catch (e) { // Do nothing; From 1300225f07cd3ae1d69bbac803667787daf2d386 Mon Sep 17 00:00:00 2001 From: "Lu, Jun" Date: Mon, 4 Nov 2024 17:59:16 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E5=90=8C=E6=97=B6=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=20React=2019=20=E5=92=8C=20React=2016?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/render.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/utils/render.ts b/src/utils/render.ts index 9dfd26edbc..71110c5e2b 100644 --- a/src/utils/render.ts +++ b/src/utils/render.ts @@ -1,6 +1,6 @@ import type { ReactElement } from 'react' import * as ReactDOM from 'react-dom' -import { type Root, createRoot as createClientRoot } from 'react-dom/client' +import { type Root } from 'react-dom/client' // 移植自rc-util: https://github.com/react-component/util/blob/master/src/React/render.ts @@ -21,9 +21,10 @@ const { version, render: reactRender, unmountComponentAtNode } = fullClone let createRoot: CreateRoot try { const mainVersion = Number((version || '').split('.')[0]) - const createReactRoot = createClientRoot || fullClone.createRoot - if (mainVersion >= 18 && createReactRoot) { - createRoot = createReactRoot + if (mainVersion >= 18) { + // eslint-disable-next-line @typescript-eslint/no-var-requires + const { createRoot: createRootV18 } = require('react-dom/client') + createRoot = createRootV18 || fullClone.createRoot } } catch (e) { // Do nothing;