Closed cmaycumber closed 2 years ago
Hey @cmaycumber! This was not possible up until now indeed. I just published v3.1.0
that adds this feature via the existing addListener
method. The documentation has been updated to reflect this, just as the Expo playground (look at ./components/DemoModal.tsx#L51-53
if you want to quickly check it out).
Let me know if this works for you and addresses your use case!
Thanks for adding this!
Still curious, would it be possible to add the onClose listeners to all the modals in the stack without having to declare it across every modal component?
Something like passing listeners to the ModalProvider
would run for every modal.
I would have to think about a way to do so that wouldn't be costly.
In the meantime, if you absolutely need this behavior, you can have all of your modals use a common wrapper component. That way you'd only use addListener
with 'onClose'
once in that wrapper component and trigger whatever logic you need from there.
I would have to think about a way to do so that wouldn't be costly.
Totally get this. Thanks for the direction.
I'm currently using shallow routing on Next Js with this library on the web. I'd like to track the modal close event so whenever a modal is closed by clicking on the backdrop I can trigger a change in the URL to remove the shallow route that's added when a modal is pushed.
Is this currently possible? Or should I extend the current modal hook functions to include my custom functionality?