-
Notifications
You must be signed in to change notification settings - Fork 3.6k
React-bootstrap duplicates a <Modal/> on dom. #2730
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
Comments
This is most likely a bug in your code, where you're mounting your component that renders the modal more than once. If you have a repro, though, we'd be glad to look at it. |
I'm not sure that is a bug in our project code, I realize this happens when you declare a Modal inside a wrapper, for example:
And the modal is a child in the wrapper:
Than the App :
The result is that the instance of the Modal is rendered 2 times in the virtual dom. I'm very curious to discuss about this approach :) |
IS there actually two Modals or do you only see 2 in the React Devtools? The latter case is probably due to Modals using a portal to render the DOM components outside the body of the document, and so you see two things called "Modal" but really it's two different parts of the Modal with the same name. |
It's actually 2 modals, this is the final virtual dom:
Can be possible that |
I am having this issue as well, and my modal is only wrapped by the container component. I have a strong feeling that it is not because of my code, but I can't be sure. Hard bug to trace. |
I solved the issue moving all modals to a top level, controlling them with a state manager instead (Redux or MobX). |
I am using redux, I can't move the modal anywhere higher, though. |
Hi, I solved this by wrapping the modal html inside a div.
Hope this help |
@RobertSigma can you post a repro on CodeSandbox? |
Had the same issue. I solved it by wrapping the modal in a View at the bottom of my code. (after the last view) Just make sure there isn't another View below it |
I had the same or similar issue, where my modal would be rendered twice |
have you looked into the webpack configuration? mui/material-ui#24641 (comment) |
Well, I'm using react, not webpack. |
I noticed a strange behaviour .
When i render a Modal component, it is duplicated.
I noticed i'm not the only one who got this problem:
https://stackoverflow.com/questions/44761650/react-bootstrap-duplicated-modal-components
Any tips how to fix the issue?
Thank you,
Andrea.
The text was updated successfully, but these errors were encountered: