-
Within the signature, this line doesn't seems to falsely claim the cached value might be undefined: Let's say I have an API endpoint which always returns an object, like a config or translations pack, whatever. It's always an object (never Similar concept is used in react useState, where - in case no initial value is passed, the type is widened with Maybe I'm missing something, but in case of setQueryData that's not the case. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
simple scenario: A query can be in The real problem is that you cannot return undefined. In v4, we've adapted the functionality and the typings are now:
so if you get undefined, you can just return undefined to bail out of state updates: |
Beta Was this translation helpful? Give feedback.
simple scenario: A query can be in
error
state and you can still callsetQueryData
on that query. In those cases, you will be handedundefined
, that's why the types reflect that.The real problem is that you cannot return undefined. In v4, we've adapted the functionality and the typings are now:
so if you get undefined, you can just return undefined to bail out of state updates: