fix: destroyOnClose fails with forceRender#232
Open
HelloAny wants to merge 2 commits intoreact-component:masterfrom
Open
fix: destroyOnClose fails with forceRender#232HelloAny wants to merge 2 commits intoreact-component:masterfrom
HelloAny wants to merge 2 commits intoreact-component:masterfrom
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.
|
afc163
reviewed
Jun 1, 2021
|
|
||
| const DialogWrap: React.FC<IDialogPropTypes> = (props: IDialogPropTypes) => { | ||
| const { visible, getContainer, forceRender, destroyOnClose = false, afterClose } = props; | ||
| const [forceRenderTime, setForceRenderTime] = React.useState<boolean>(forceRender); |
afc163
reviewed
Jun 1, 2021
| } | ||
|
|
||
| // Destroy on close will remove wrapped div | ||
| if (!forceRender && destroyOnClose && !animatedVisible) { |
Member
|
3.x 也有这个问题。😳 |
Member
|
冲突了 |
Member
|
ping @HelloAny |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ant-design/ant-design#28847
解决
destroyOnClose和forceRender都设置为true时destroyOnClose失效原因:当
forceRender设置为true时,判断是否删除子节点的语句失效方案:为
forceRender增加一层缓存,当第一次打开Modal时设置forceRender为false此外,感觉antd文档里关于

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