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

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sunxd-lab
Copy link

@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

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