-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
I'm wanting to create a self contained Dialog that has some logic in it as well. When the OK button is pressed, the business logic executes and the modal is closed. Is it possible to call hideModal from within the dialog itself?
const ConfirmationDialog: React.FC<Props> = ({ title, description, ...props }) => {
const { hideModal } = useModal();
const handleClose = () => {
// Do stuff here
...
hideModal(); // What is the modal id?
};
return (
<Dialog {...props}>
<DialogTitle>{title}</DialogTitle>
<DialogContent>
<DialogContentText>{description}</DialogContentText>
</DialogContent>
<DialogActions>
<Button onClick={handleClose} color="primary">
Ok
</Button>
</DialogActions>
</Dialog>
);
};
Meanwhile somewhere else in my app:
showModal(ConfirmationDialog, {
title: 'Hello World',
description: 'description text',
});
Thanks for a great library!
Metadata
Metadata
Assignees
Labels
No labels