react-router: Change URL without triggering re-route
I’m trying to implement a gallery that behaves like Instagram’s, but I’m having trouble due to the fact that I can’t change the URL without triggering a full re-route.
What I’d like to be able to do is open a modal from an image gallery and change the URL such that copying/pasting the URL results in displaying just that image and not the gallery behind it.
In other words, I have a set of routes that looks like this:
<Routes location="history">
<Route name="index" path="/" handler={App}>
<Route name="featuredGallery" path="/items/featured/" handler={FeaturedGallery} />
<Route name="itemDetail" path="/items/:id/" handler={ItemDetail} />
<DefaultRoute handler={Homepage} />
</Route>
</Routes>
And I’d like to be able to visit /items/featured/ and click an item to open a modal that changes the URL to, eg, /items/10/?modal=true without triggering the ItemDetail handler (I will render it inside the modal in FeaturedGallery when an item in the gallery is clicked).
However, if /items/10/?modal=true were to be pasted into a new browser window, it should trigger the ItemDetail handler rather than FeaturedGallery.
If there’s a way to do this already, I haven’t been able to figure it out. Any help is appreciated!
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Reactions: 1
- Comments: 15 (6 by maintainers)
@rpflorence Yeah, your description is correct. I’m trying to get the same behavior as this page (http://instagram.com/johnthedebs) so that when you copy/paste a link with one of the modals open it takes you directly to that image (and only that image, with no gallery underneath).
I figured there may have been a design decision not to support that type of behavior since it seems to complicate things. If that’s the case, I’ll try to figure something else out. Thanks for the quick replies!