Modals #127
-
I have always struggled with modals in React. What is the suggested way to handle them in React Location? For a little more context: The issue I that some modals are considered "global", that is they are needed all over the react tree, an example might be a login modal, there might be several places on the page(s) that would open this modal. Does it make sense for modals to be part of the routing? Should they be hash routes? How do you handle modals? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
If you want the modal visibility to be tied to the history and location, then yes, it should be based on the url and routing. How you do that is up to you. Some modals are hierarchical, some are global. If it’s the former, it makes sense to have it be a nested route that maybe renders into a portal. If it’s the latter, it probably makes more sense to render it at the root based on the presence of a search param. |
Beta Was this translation helpful? Give feedback.
If you want the modal visibility to be tied to the history and location, then yes, it should be based on the url and routing. How you do that is up to you. Some modals are hierarchical, some are global. If it’s the former, it makes sense to have it be a nested route that maybe renders into a portal. If it’s the latter, it probably makes more sense to render it at the root based on the presence of a search param.