T
TanStack2mo ago
itchy-amethyst

set defaultViewTransition to false when search params are updating.

I'm doing a search feature, but when I trigger the navigate (with new search params so), there is always the view transition (so my input is doing opacity 0 to 1 on each key..). I tried this but doesn't work :
defaultViewTransition: {
types: ({ fromLocation, toLocation, pathChanged }) => {
let direction = 'none'

if (fromLocation && pathChanged) {
const fromIndex = fromLocation.state.__TSR_index
const toIndex = toLocation.state.__TSR_index

direction = fromIndex > toIndex ? 'right' : 'left'
}

return [`slide-${direction}`]
}
}
defaultViewTransition: {
types: ({ fromLocation, toLocation, pathChanged }) => {
let direction = 'none'

if (fromLocation && pathChanged) {
const fromIndex = fromLocation.state.__TSR_index
const toIndex = toLocation.state.__TSR_index

direction = fromIndex > toIndex ? 'right' : 'left'
}

return [`slide-${direction}`]
}
}
3 Replies
itchy-amethyst
itchy-amethystOP2mo ago
Ok I just found viewTransition: false with the navigate function. Seems to work. But, I would like to know if it's possible to enable defaultViewTransition only when path is changing (so in global).
itchy-amethyst
itchy-amethyst2mo ago
i dont think so, but this should be doable. we would need to allow defaultViewTransition to be a function are you interested in contributing this?
itchy-amethyst
itchy-amethystOP2mo ago
Yes, I can try ! Do you any tips to do that ahah ?

Did you find this page helpful?