Comments (1)
You can have multiple modal dialogs in the same component. Consider a page with a save-modal and a discard-modal as below. In my example, I'm not using the ModalContainer's onClose nor the ModalDialog's onClose. But this example should still work if you are using them.
You'll want a flag per modal dialog in your state object.
state = {
isShowingSaveModal: false,
isShowingDiscardModal: false
};
Then, in the render you can have something like this:
{/* Below is the save confirmation modal dialog */}
<div>
{this.state.isShowingSaveModal &&
<ModalContainer>
<ModalDialog>
<h4>Save Changes?</h4>
<p>Are you sure you wish to save the changes you have made?</p>
<NoButton className={'btn btn-md'} onClick={() => this.cancelSave()}>No</NoButton>
<YesButton className={'btn btn-md btn-brand'} onClick={() => this.save()}>Yes</YesButton>
</ModalDialog>
</ModalContainer>}
</div>
{/* Below is the discard confirmation modal dialog */}
<div>
{this.state.isShowingDiscardModal &&
<ModalContainer>
<ModalDialog>
<h4>Discard Changes?</h4>
<p>Are you sure you wish to discard the changes you have made?</p>
<NoButton className={'btn btn-md btn-brand'} onClick={() => this.cancelDiscard()}>No</NoButton>
<YesButton className={'btn btn-md'} onClick={() => this.discard()}>Yes</YesButton>
</ModalDialog>
</ModalContainer>}
</div>
This has worked successfully for me. I hope this helps.
Cheers!
from react-modal-dialog.
Related Issues (20)
- prevent closing when clicking on container but not on dialog HOT 4
- Heavy dependencies HOT 3
- Modal is positioned at the bottom of the page HOT 2
- Modal cannot be closed while loading HOT 1
- React 15.5.4 - Warning: Accessing PropTypes via the main React package is deprecated. HOT 2
- How to remove the close icon from the modal HOT 2
- Close icon removed with overflow:scroll
- Way to add a /route to URL tag when modal is opened.
- Cannot read property 'number' of undefined HOT 5
- React 16 peer dependency HOT 3
- Uncaught Error: Element type is invalid: expected a string
- Spinner not working
- Undefined number in CloseCircle.js HOT 4
- Calculate top wrongly HOT 1
- Refs problem in react 15
- ModalDialog chilren redux-form
- Not properly displaying on mobile device screens
- is this module compatible with react 16 ? got Error: Cannot find module 'inline-style-prefixer/static' HOT 2
- Hosted link does not work HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-modal-dialog.