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]
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This setter & getter separation concept is inspired by
useAtomValue
&useSetAtom
fromjotai
(state management library). This separation will add more granular and semantical support for the user.Functions
useQueryValue
useSetQuery
useQueryValues
useSetQueries
Use Cases
useQueryValue
&useQueryValues
)useQueryValues
&useSetQueries
)useQueryState
&useQueryStates
are still exist and used on the component that needs to read & write the query at the same time likes the search filter.Thanks 🌟.
Beta Was this translation helpful? Give feedback.
All reactions