Skip to content

Change URL without triggering re-route #266

@johnthedebs

Description

@johnthedebs

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions