T
TanStack•3y ago
fascinating-indigo

Update search params without rerender

Hey 👋 I want to know, if it is possible to update search params of the current route, without a rerender/remount. Use-case I want, additional to the filter, to store the selected-row-state in the search-params. Now a row-selection should not cause a remount. It should just add the info to the search-params. When the url is reloaded, the information should be used to select the corresponding row initially. Is that possible? Or how you would solve such an use-case? Thanks
4 Replies
ambitious-aqua
ambitious-aqua•3y ago
Also curious about this, afaik there's no functionality in tanstack router to do this
sensitive-blue
sensitive-blue•3y ago
I am updating search params to manage filters and to my eyes it works extremely well. I have multi select dropdowns which use onChange to set the new search params state using
navigate({
search: prev => ({
...prev,
countryCodes: [blah]
})
})
navigate({
search: prev => ({
...prev,
countryCodes: [blah]
})
})
My multi selects stay open while using them and the rest of the data on the page updates seamlessly at the same time based on the new params. I don't see why you couldn't just use the search params as the source of truth for row selection state. E.g
checked={search.rows.includes(row.id)}
checked={search.rows.includes(row.id)}
and
onCheckedChange={navigate ... etc
onCheckedChange={navigate ... etc
Maybe I am misunderstanding the requirements
ambitious-aqua
ambitious-aqua•3y ago
In my case, I have a search input element that is added as a url parameter. But I'd like to show a loading state in the input field when a user adds a search query, which will not show because the page will navigate and preload the new set of data.
robust-apricot
robust-apricot•2y ago
I have the same problem, also when I change the sub-page in the layout, the whole page is rerendered, I want to update only the Outlet in the layout and not the whole layout. I created a github thread about it https://github.com/TanStack/router/discussions/1460

Did you find this page helpful?