DEV Community

Discussion on: How to make routable modals in react with react-router

Collapse
 
ausmurp profile image
Austin Murphy

You would need to subscribe to the history listener to make this work- something I recently did in a project.

That being said, there will also be issues with hostory.goBack() to close the modal, if it wasn't opened from the parent page. I ended up pushing a new route to the parent page to close the model - history listener listens for a MODAL_TOKEN unique string (id of modal) on the page as a hash (page/route#the-modal). If there and modal is closed, open. If not there and modal is open, close.

I plan on posting about an advanced router modal soon. Hope this helps.