From c88b4cb7845a90a36fb1b1d39b802aeb6ab5354b Mon Sep 17 00:00:00 2001 From: "Lu, Jun" Date: Fri, 1 Nov 2024 13:20:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=BC=E5=AE=B9=E5=9C=A8=20React=2019?= =?UTF-8?q?=20=E7=8E=AF=E5=A2=83=E4=B8=8B=E7=9A=84=20Toast=20=E7=BB=84?= =?UTF-8?q?=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;