'Props onClose doesn't work on my Modal (Material UI)
I am currently trying to close my modal by setting the state variable openModal to false with the function handleClose by clicking on the background. I thought that using the onClose props would do it but when I am clicking on the background, nothing happens. It was working fine before I put my Modal in a component. Any Idea how can I solve this ?
Thank you:)
const ModalReservation = ({openModal, setOpenModal}) => {
...
const handleClose = () => setOpenModal(false);
return (
{openModal ?
<Modal
open={openModal}
onClose={handleClose}
aria-labelledby="modal-modal-title"
aria-describedby="modal-modal-description"
>
...
Solution 1:[1]
I've made a dumb mistake in my other page instead of giving the props setOpenModal I gave setOpen.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | MrBigboka |
