Replies: 1 comment 2 replies
-
I think what we wanted to come up with is an @Newbie012 is the |
Beta Was this translation helpful? Give feedback.
2 replies
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.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi React Query community!
I have a question about
queryKey
best practices when class instances are used withinqueryFn
s. Suppose I have thisuseQuery
whosequeryFn
fetches from storage:While it is true that
storage
could change implementation under the hood when its own parameters change, its accepted in our codebase as a static instance we use to reference persisted storage values (and I feel that this would be true for many codebases as well). However, ESLint tells us that the class instance should be declared within thequeryKey
.I've also seen this discussion suggesting that we can declare a
queryKeyHashFn
to generate a hashed string from a non-serializable query key. However, it is safe to assume that the storage instance is static and it feels unnecessary to populate our query cache with information about this storage instance (and even error prone since we're now adding manually written serialization logic).Would it be safe to ignore class instance references in
queryKey
? If so, are there best practices around what we can avoid declaring in query keys? Would it even make sense to update the ESLint plugin to ignore class references?Sandbox: https://codesandbox.io/s/react-query-object-keys-forked-j4n59q?file=/src/useMap.ts
Thanks in advnace!
Beta Was this translation helpful? Give feedback.
All reactions