Closed Sexual closed 6 years ago
Can you post your route setup code? Both routes (modal and the component behind) need to match the current location. Two common problems are using <Switch>
or using exact
on your parent route.
<Route exact path="/developer" component={DeveloperWebhooks}/>
<ModalRoute exact path="/developer/webhooks/:id" parentPath="/developer" component={DeveloperWebhook}/>
<ModalContainer history={history} containerClassName="modal__overlay" backdropClassName="modal__backdrop" modalClassName="modal__dialog"/>
Not using a switch
I think the problem is the exact
prop on the Route
. That means it will only match if the location exactly matches /developer
(and not if the current path is /developer/webhooks/foobar
).
That does appear to solve it, but limits me doing other routes under the /developer
path. Guess I'll have to use a different route.
Thanks for the help. This should probably be added to the readme.
You have some other options: you can render the other routes that are under /developer
in the a component mounted at /developer
, using a Switch
. You can also use wildcards in the ModalRoute path to match just the end: */webhooks/:id
, if you find the need. Let's keep this issue open until I get around to documenting this a bit better. Thanks for the report.
@davidmfoley Hi! If I will be going to modal route link from various routes , how can I save visibility of the last route of component without setting property parentPath
? because parentPath
may be variously, like as /
or /search?q=bla
Just I have same problem but my implementing some another. I setting globally modal route and I want to route from various components, but when I do it then previous route data has been removed from DOM
When a link is clicked that routes to a modal, I can't get the parent path to show in the background like in the examples. The modal itself shows fine and when clicking the backdrop it does go back to the parent route.
I'm using
connected-react-router
and redux.