Typescript discriminating data based on isLoading state #1475
tomchambers2
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
It is set up that way. But when you destructure, the TypeScript compiler loses that information. Try to keep it as one object instead of destructuring. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently you need to keep checking if data exists in order to use it. Would it be possible to set the types so that we can use the
data
property safely ifisLoading
orisFetching
has been checked?A type that looks like
So you could do
(From memory) I think that react-query does something like this?
Beta Was this translation helpful? Give feedback.
All reactions