-
-
Notifications
You must be signed in to change notification settings - Fork 202
fix: destroyOnClose fails with forceRender #232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/react-component/dialog/ookx04a0g |
Codecov Report
@@ Coverage Diff @@
## master #232 +/- ##
==========================================
+ Coverage 98.10% 98.17% +0.06%
==========================================
Files 6 6
Lines 158 164 +6
Branches 46 47 +1
==========================================
+ Hits 155 161 +6
Misses 2 2
Partials 1 1
Continue to review full report at Codecov.
|
|
|
||
| const DialogWrap: React.FC<IDialogPropTypes> = (props: IDialogPropTypes) => { | ||
| const { visible, getContainer, forceRender, destroyOnClose = false, afterClose } = props; | ||
| const [forceRenderTime, setForceRenderTime] = React.useState<boolean>(forceRender); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forceRenderTime 是啥含义?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该是forceRender的映射,后续进行状态管理
| } | ||
|
|
||
| // Destroy on close will remove wrapped div | ||
| if (!forceRender && destroyOnClose && !animatedVisible) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是不是直接把 !forceRender 去掉就行了?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
直接去掉会导致forceRender这个属性失效😅
|
3.x 也有这个问题。😳 |
|
冲突了 |
|
ping @HelloAny |
ant-design/ant-design#28847
解决
destroyOnClose和forceRender都设置为true时destroyOnClose失效原因:当
forceRender设置为true时,判断是否删除子节点的语句失效方案:为
forceRender增加一层缓存,当第一次打开Modal时设置forceRender为false此外,感觉antd文档里关于

forceRender部分的描述不是很清晰,个人理解为首次未打开Modal可获取其中的dom觉得可以和
dialog的文档稍作同步