getQueryData & Selectors. #4093
-
Hey, I was wondering about getQueryData with selectors, Is it possible to target selectors with getQueryData ? it could be nice to have a hook getQuerySelector(queryKey, selectorKey) 🤔 or I should just use selectors like mention here https://tkdodo.eu/blog/react-query-data-transformations#3-using-the-select-option |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
getQueryData
gets the data from the cache. There is only one structure in the cache. Theselect
option is "per observer", so every useQuery call can transform data like they see fit, and additionally, only subscribe to the transformation result.getQueryData
doesn't create a subscription, so a selector is unnecessary. You can just do: