Closed tunztunztunz closed 1 year ago
hi @tunztunztunz! i'm not sure where you find that old info as currentModal
has always been the way to go since pretty much the very first version of the library:
but in case the way to use it wasn't super clear: let's say you're writing some code inside a LoginModal.tsx
file. if we had isModalOpen
, you could have just been able to access props.modal.isModalOpen
and check if that was the case. however, if you were to switch to, let's say, your RegistrationModal.tsx
file: you would have not be able to know if LoginModal
was open, you'd only know if RegistrationModal
was (limitation due to the nature of isModalOpen
).
that's why we went for currentModal
as it returns the modal name you've provided when adding your modal to createModalStack()
(1st) object. thanks to that, now even if you're inside RegistrationModal
, you can check if props.modal.currentModal === 'RegistrationModal'
or even props.modal.currentModal === 'LoginModal'
.
and if no modal is opened, currentModal
will simply be null
. hope that helped, let me know if not!
I stumbled upon some old information that suggested I use
isModalOpen
, but that appears to be deprecated. I seecurrentModal
, but I'm not sure how I can use that in the same effect asisModalOpen
. I don't see any examples.