-
-
Notifications
You must be signed in to change notification settings - Fork 187
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
fix: destroyOnClose fails with forceRender #232
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.
|
@@ -14,14 +14,22 @@ import { IDialogPropTypes } from './IDialogPropTypes'; | |||
|
|||
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的映射,后续进行状态管理
@@ -33,15 +41,16 @@ const DialogWrap: React.FC<IDialogPropTypes> = (props: IDialogPropTypes) => { | |||
} | |||
|
|||
// 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
的文档稍作同步