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

Dialog Child Component unmounts every time you reopen it #10572

Closed
1 task done
AlgusDark opened this issue Mar 8, 2018 · 5 comments
Closed
1 task done

Dialog Child Component unmounts every time you reopen it #10572

AlgusDark opened this issue Mar 8, 2018 · 5 comments
Labels
component: dialog This is the name of the generic UI component, not the React module! support: question Community support but can be turned into an improvement

Comments

@AlgusDark
Copy link

I believe that when you open/close your dialog, the children components should call componentWillReceiveProps, but instead is unmounting/mounting every time.

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

Expected Behavior

Dialog child components should be mounted only one time.

Current Behavior

Every time you close your Dialog and re-open your Dialog, the children components is being mounted again.

Steps to Reproduce (for bugs)

https://codesandbox.io/s/oly01xlq0z

Context

I just want to update the Select Combo Box inside a Dialog when it receives a different prop, handle it with componentWillReceiveProps and setState. Right now I'm using componentDidMount and and setState.

Your Environment

Tech Version
Material-UI 1.0.0-beta.34
React 16.2.0
browser Chrome
@oliviertassinari oliviertassinari added support: question Community support but can be turned into an improvement component: dialog This is the name of the generic UI component, not the React module! labels Mar 8, 2018
@oliviertassinari
Copy link
Member

@AlgusDark The Dialog component inherits from the Modal component:

capture d ecran 2018-03-08 a 21 54 34

The Modal component implements a keepMounted property that answers your use case.

capture d ecran 2018-03-08 a 21 55 23

https://codesandbox.io/s/oow2w5y5p5

@AlgusDark
Copy link
Author

Thanks!

@cjauvin
Copy link

cjauvin commented Jun 29, 2023

I know this is an old issue, but I'm confused about this, and I cannot find information about it elsewhere: should keepMounted control what is happening when the dialog's open becomes false? From what I observe it seems to have no effect (i.e. the dialog is kept mounted whether open is true or false, whatever the value of keepMounted), but I would actually like to have this control (because my dialog contains a form, and resetting its state is complex, and unmounting would be an easy way).

@Tasin5541
Copy link

I know this is an old issue, but I'm confused about this, and I cannot find information about it elsewhere: should keepMounted control what is happening when the dialog's open becomes false? From what I observe it seems to have no effect (i.e. the dialog is kept mounted whether open is true or false, whatever the value of keepMounted), but I would actually like to have this control (because my dialog contains a form, and resetting its state is complex, and unmounting would be an easy way).

Having the same issue.

@hero-oceansmart
Copy link

not working for me. I have array Dialog. When i close modal A ( using keepMounted = true ) then re-open this Dialog will not unmounted. But if i close Dialog A and open Dialog B. the content will unmounted.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: dialog This is the name of the generic UI component, not the React module! support: question Community support but can be turned into an improvement
Projects
None yet
Development

No branches or pull requests

5 participants