Replies: 1 comment 1 reply
|
You can do this trivially with the existing API: // Read-only
const [value] = useQueryState('key')
// Write-only
const [, setValue] = useQueryState('key')Since all hooks with the same key are synced together, you can separate read and write without any issues. The state updater function is also referentially stable across renders. If you really want to abstract those into functions: function useQueryValue() {
return useQueryState('key')[0]
}
function useSetQuery() {
return useQueryState('key')[1]
} |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
This setter & getter separation concept is inspired by
useAtomValue&useSetAtomfromjotai(state management library). This separation will add more granular and semantical support for the user.Functions
useQueryValueuseSetQueryuseQueryValuesuseSetQueriesUse Cases
useQueryValue&useQueryValues)useQueryValues&useSetQueries)useQueryState&useQueryStatesare still exist and used on the component that needs to read & write the query at the same time likes the search filter.Thanks 🌟.
All reactions