You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the modal example in the react-router v6 source, and I want to display the contents of a route in the modal.
I have my routes defined like this:
<Routeslocation={state?.backgroundLocation||location}><Routepath="/"element={<Layout/>}><Routeindexelement={<Home/>}/><Routepath="gallery/:counter"element={<Gallery/>}/><Routepath="*"element={<NoMatch/>}/></Route></Routes>{/* Show the modal when a `backgroundLocation` is set */}{state?.backgroundLocation&&(<Routes><Routepath="/modal/:counter"element={<Modal/>}/></Routes>)}
And when the user clicks the Modal link, I want to display the contents of the gallery/:counter route in the modal, but I'm not sure how to trigger the route apart from using the <Navigate /> component, which causes the whole page to redirect.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Here is a codesandbox that recreates the problem.
I am using the modal example in the react-router v6 source, and I want to display the contents of a route in the modal.
I have my routes defined like this:
And when the user clicks the
Modal
link, I want to display the contents of thegallery/:counter
route in the modal, but I'm not sure how to trigger the route apart from using the<Navigate />
component, which causes the whole page to redirect.Beta Was this translation helpful? Give feedback.
All reactions