Skip to content
This repository was archived by the owner on Apr 7, 2024. It is now read-only.

fix: react18 createRoot渲染模式,严格模式下,渲染错误问题#350

Open
sunxd-lab wants to merge 1 commit intoalibaba:masterfrom
sunxd-lab:strictMode
Open

fix: react18 createRoot渲染模式,严格模式下,渲染错误问题#350
sunxd-lab wants to merge 1 commit intoalibaba:masterfrom
sunxd-lab:strictMode

Conversation

@sunxd-lab
Copy link
Copy Markdown

@sunxd-lab sunxd-lab commented Jan 4, 2024

在react18版本,使用BaseTable, 用createRoot方式渲染,App被严格模式包裹时,会导致组件无法正确渲染

import ReactDOM from "react-dom/client";
const root = ReactDOM.createRoot(
  document.getElementById("root") as HTMLElement
);
root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);

由于react18在严格模式下,对于类组件会先调用一次 componentWillUnmount, 导致rootSubscription被取消订阅
image

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jan 4, 2024

CLA assistant check
All committers have signed the CLA.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants