reduxjs / redux-toolkit

The official, opinionated, batteries-included toolset for efficient Redux development
https://redux-toolkit.js.org
MIT License
10.74k stars 1.18k forks source link

Status is deprecated #3246

Closed BasmaNabil closed 1 year ago

BasmaNabil commented 1 year ago

I was using status to get the state of the query('pending, rejected, fullfilled'), how can this be optained now form (isLoading, isFetching,....etc) or from where can i got this query state?

const {data, isLoading, isError, isFetching, status } = useGetUsersQuery()

lxm7 commented 1 year ago

in my case for needing the status to be complete and on subsequent calls from different handlers in the same state scope, i did the following on a customWatcher function:

useWatchForTruthy(!isFetching && isSuccess, () => {

phryneas commented 1 year ago

I'm honestly a bit irritated. status has been deprecated since before RTK Query even was a part of Redux Toolkit.

We never removed it because having it there doesn't hurt, but we don't want people to use it, since status doesn't tell you the whole story. Something could be isSuccessful and isFetching at the same time - that cannot be expressed as status.

So yeah, please use the isLoading etc. flags instead.