useQuery
for managing user prefs in localStorage
#1303
Unanswered
DannyDelott
asked this question in
Show and tell
Replies: 1 comment 3 replies
-
I thought |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Treating
window.localStorage
as a just another side-effect client can be tricky in React, because changes to localStorage do not cause re-renders on their own. For that, a React binding of some kind is required.Using react-query, we wrote a custom hook,
usePref
that lets components get/set localStorage values which then trigger re-renders as you'd expect.Beta Was this translation helpful? Give feedback.
All reactions