T
TanStack7d ago
xenial-black

States in url

Hey, I have a page with 3 "tabs", when you change tab it just slides a part of the content to show the corresponding tab. Now I would like to save several states of the page into URL to allow navigating to this specific tab. For the moment it work for the base value of those states, but I would like to update the URL to match the state changes. I'm thinking of implementing it using the router and outlets, but i'm not sure if I can re-create the same behavior. Like I can scroll horizontally with a finger to move from tabs to tabs. I don't visualize how could I do this with an outlet. Otherwise, is it okay to update the URL without actually changing any router page or smthing ? In the past I used an external library that added some hooks to make react states auto persisted in the url. Could it work with react-router or can it lead to unexpected behaviors ? Thanks
1 Reply
ambitious-aqua
ambitious-aqua7d ago
Otherwise, is it okay to update the URL without actually changing any router page or smthing ?
absolutely just call navigate(to:'.', search: {...})

Did you find this page helpful?