Allow setting default transition options per-query
franky47 opened this issue · 2 comments
franky47 commented
Saves having to pass the same { scroll: false }
to every call to the state updater function.
Values would be merged: Next.js defaults, then values specified at the hook level, then values specified when calling of the state updater function.
Example API:
const [, setState] = useQueryState('key', {
...queryTypes.string.withDefault('foo'),
scroll: false
})
setState('bar') // will not scroll
setState('egg', { scroll: true }) // will scroll
For useQueryStates
:
const [, setState] = useQueryStates({
foo: queryTypes.string,
bar: queryTypes.integer
},
{
scroll: false
})
franky47 commented
Note: it could make sense to have scroll: false
as a default value, though that would be a breaking change as Next.js does a scroll to top by default when using the router.
franky47 commented
Implemented in 1.8.0