A simple programmatic interface for rendering your modal components.
It would be nice if we could render a modal on demand, rather than embedding the component inside our views directly.
First, Declare the ModalContainer
at the root of your application
const App = () => {
<div>
<Router>
stuff
</Router>
<ModalContainer />
</div>
}
Next, whenever you want to programmatically render a modal, use the renderModal
function, and pass your component.
renderModal(props => {
return (
<Dialog {...props}>
<DialogContent>Rendered Modal</DialogContent>
</Dialog>
);
});
Simple as that.
MIT
Endurance Idehen