alibaba / ali-react-table

Performent, flexible and modern React table component.
https://ali-react-table.js.org/
MIT License
956 stars 312 forks source link

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

Open sunxd-lab opened 10 months ago

sunxd-lab commented 10 months ago

在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 commented 10 months ago

CLA assistant check
All committers have signed the CLA.