Help Using react-query #3404
-
I updated my react packages and now im getting error when I try to use this code: Rest Call
Usage
If I omit the "isLoading"" the error dissapear. Can anyone help me, please? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Did you update to typescript 4.6 ? |
Beta Was this translation helpful? Give feedback.
-
I've put your code into typescript playground: TS 4.6 has a new feature for better Control Flow Analysis for Destructured Discriminated Unions, which is exactly what's kicking in here. Since you are checking for |
Beta Was this translation helpful? Give feedback.
I've put your code into typescript playground:
TS 4.6 has a new feature for better Control Flow Analysis for Destructured Discriminated Unions, which is exactly what's kicking in here. Since you are checking for
isLoading
, and react-query's types are defined asdata
beingundefined
if you are inloading
state, the compiler now knows that the length check is unnecessary, becausedata
cannot be an array during loading state :)