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 have a application where generic components are managing search and filter states also search and filter states are using navigation but use search is not updating.
navigate is changing url but its not rerunning useMemo when console log without use effect Appliction is not rerunning on change of searchParams
for this console log "FilterBar.tsx:122" all latest values are available while console log in route page is not updating
"""
const params = Route.useSearch()
console.log(params)
"""
Defination of searchValidation is done like
"""
export const ZodListQuerySchemaExtend = {
page: fallback(number().optional(), 1).default(1),
search: fallback(string().optional(), ''),
order_by: fallback(string().optional(), ''),
I checked recreation of nested state with different object works but could that be mentioned on use search params docs for new object needs to be created ,as react state normally re run if first level object is recreated into new object so for garbage collection saving our product uses reassign to same object reference on nested object but for this case it goes differently than react state
Also I am aware of use memo and use callback not trigging on nested items if reference of nested item is not changed
Which project does this relate to?
Router
Describe the bug
I have a application where generic components are managing search and filter states also search and filter states are using navigation but use search is not updating.
navigate is changing url but its not rerunning useMemo when console log without use effect Appliction is not rerunning on change of searchParams
Your Example Website or App
https://stackblitz.com/edit/tanstack-router-5lj1t6?file=src%2Froutes%2Findex.tsx,src%2Froutes%2F__root.tsx&preset=node
Steps to Reproduce the Bug or Issue
my on Filter/search change after debounce for search is something like
const onFilterChange = useCallback(
(v: T): void | Promise => {
navigate({
to: '.',
search: (c) => {
console.log('FilterBar.tsx:122', c)
const newValue = v
for this console log "FilterBar.tsx:122" all latest values are available while console log in route page is not updating
"""
const params = Route.useSearch()
console.log(params)
"""
Defination of searchValidation is done like
"""
export const ZodListQuerySchemaExtend = {
page: fallback(number().optional(), 1).default(1),
search: fallback(string().optional(), ''),
order_by: fallback(string().optional(), ''),
}
const searchSchema = z.object({
q: fallback(z.object(ZodListQuerySchemaExtend), { page: 1 }),
})
export const Route = createFileRoute('')({
component: Component,
validateSearch: zodSearchValidator(searchSchema),
})
"""
Expected behavior
console log in Component should be updated when url changes
Screenshots or Videos
No response
Platform
Additional context
No response
The text was updated successfully, but these errors were encountered: