d3george / slash-admin

A modern react admin. It is based on react 18, vite and TypeScript. It's fast !
https://admin.slashspaces.com/
MIT License
1.49k stars 218 forks source link

fix: 解决 Editor 在 Modal 组件中报错 #69

Closed Jackie-Lin closed 2 months ago

Jackie-Lin commented 2 months ago

解决 Antd 5,Editor 作为内部元素的渲染 Modal 中,会直接报错的问题

vercel[bot] commented 2 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
slash-admin ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 20, 2024 9:26am
d3george commented 2 months ago

这是在解决什么问题?

Jackie-Lin commented 2 months ago

这是在解决什么问题? 问题:项目 components 里封装的 editor (富文本) 组件,如果直接在 Modal (弹窗) 组件中直接引用,会直接报错 原因:antd 5 Modal 组件的渲染时序,是随 React 生命周期走,所以 Modal 中的内部组件 (使用 editor 作为内部组件),也应随 React 生命周期 解决:通过 useEffect 把 editor 渲染时序与 React 生命周期 同步,避免直接 modal 直接引入 editor,从而报错,无法运行