Avoid null keys with enabled option #2982
-
Hello everyone 👋 , I don't know if it's the expected behaviour but I have "null" keys in my cache even when using the I'm using a hook for fetching a collaborator by id const useCollaborator(id?: number) {
return useQuery(["collaborators", id], fetchCollaborator, {
enabled: !!id
})
} I still have a cache with the following keys Is there a way to avoid that ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The query should show up as |
Beta Was this translation helpful? Give feedback.
The query should show up as
disabled
in the devtools. There is no way to avoid that, because the query has been created, even if it's disabled. You could pre-fill it withinitialData
, and you can trigger a fetch withrefetch
returned fromuseQuery
even if the query is disabled. Does the cache entry bother you?