Hi there,
I was looking for a similar approach to use modals with a hook like this, but I was wondering if something like this would be possible, cause this would be a very nice approach:
const { isModalOpen, openModal, closeModal } = useModal(<div>This is my modal</div>);
So you are able to pass elements into the useModal hook so you do not have to put any <Modal> logic into the DOM itself, and without passing props either. This is a similar library that allows you to do that, but unfortunately not really active and has some issues. But I think that would be a very nice approach, not sure if it's possible without having to change a lot of things though.
I just think that it would be a nice idea, I would really prefer this method myself to keep my modals out of the structure itself.
Hi there,
I was looking for a similar approach to use modals with a hook like this, but I was wondering if something like this would be possible, cause this would be a very nice approach:
So you are able to pass elements into the
useModalhook so you do not have to put any<Modal>logic into the DOM itself, and without passing props either. This is a similar library that allows you to do that, but unfortunately not really active and has some issues. But I think that would be a very nice approach, not sure if it's possible without having to change a lot of things though.I just think that it would be a nice idea, I would really prefer this method myself to keep my modals out of the structure itself.