Skip to content
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

Modal Children not destory when use ({visible && <Content />}) #28612

Closed
1 task
cxyxc opened this issue Dec 30, 2020 · 6 comments
Closed
1 task

Modal Children not destory when use ({visible && <Content />}) #28612

cxyxc opened this issue Dec 30, 2020 · 6 comments
Assignees
Labels
🐛 Bug Ant Design Team had proved that this is a bug. Inactive

Comments

@cxyxc
Copy link

cxyxc commented Dec 30, 2020

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

When 4.9.1 I can use (visible && <ChildrenContent/>) in Modal, but 4.9.2 is useless. I should use destoryOnClose but too many code to transform.

I think this commit have an impact on this issue. Please help me. Thanks very much.

优化 Modal useModal 性能,避免元素渲染导致组件渲染。#28122 @TotooriaHyperion

What is expected?

I can use (visible && <ChilerenContent />) to destory my component.

What is actually happening?

I can not

Environment Info
antd 4.9.2
React 16.x/17.x
System mac
Browser chrome
@fsyud
Copy link

fsyud commented Dec 30, 2020

I have the same problem

@shaodahong shaodahong added the 🐛 Bug Ant Design Team had proved that this is a bug. label Dec 30, 2020
@shaodahong
Copy link
Member

It's cause by react-component/dialog#212, @zombieJ

@TotooriaHyperion
Copy link
Contributor

TotooriaHyperion commented Dec 30, 2020

@cxyxc
#28122 only affects usage of

const [modal] = Modal.useModal();
return <button onClick={() => modal.confirm(...)}>Confirm</button>

check
react-component/dialog#212
this wraps content into a MemoChildren, and prevent any update triggered by visible change.

@shangyilim
Copy link
Contributor

@cxyxc you could use the forceRender to rerender the child:

<Dialog forceRender >
{visible && <ChildrenContent/>}
</Dialog>

@gmoniava
Copy link

gmoniava commented Jan 27, 2021

@zombieJ @shangyilim I have same problem, react-component/dialog#212, was a breaking change,
it broke some my apps where I used to rely that

visible && <ChildrenContent/>

would unmount <ChildrenContent/> on change of visible, but now it doesn't anymore. So it broke my apps where I had that assumption.

@afc163
Copy link
Member

afc163 commented Nov 6, 2022

Sorry, you should use destoryOnClose in this situation.

@afc163 afc163 closed this as completed Nov 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Ant Design Team had proved that this is a bug. Inactive
Projects
None yet
Development

No branches or pull requests

8 participants