I was using the status
flag in the redux-toolkit/query
to indicate if the state is pending
or fulfilled
or rejected
, but status
is now deprecated. How can I use the combination of isLoading
, isFetching
, isSuccess
to get the query state?
I think when isLoading
and isFetching
are false and isSuccess
is true, then it is fullfilled?
const {
data,
isLoading,
isError,
isFetching,
isSuccess,
status
} = useGetUsersQuery()
Your const is fine so far. I would solve solve this by simply using if-statements in that case. So maybe you could use some handling like this to take action:
if (isLoading || isFetching) { ... }
else if (isSuccess) { ... }
else if (isError) { ... }
For this you can proceed on your prefered action you want to do based on your state.