Replies: 2 comments 5 replies
|
yo, i feel u. the v5 naming shift from tbh the reason they split it is to separate the data state ( if u miss the old if u really need a single string field for downstream props, u might have to just wrap the hook and derive a custom status like |
|
You can recover the v4 The mapping:
So your "nascent" idea is already there, just in a different field: const { status, fetchStatus, isLoading, isPending, isFetching } = useQuery(...);
// Hard-no-data-and-actively-loading (the thing you were missing):
const isLoading_v4_compat = status === 'pending' && fetchStatus === 'fetching';
// ^ identical to `isLoading` from v5's flag, which TanStack added back specifically for this caseA quick look at the source confirms If your refactor pain came from reading
The reason v5 split it: Refs: |
Uh oh!
There was an error while loading. Please reload this page.
Just curious if there was a consideration at any point towards possibly splitting the current
pendingstatus intoloadingand a fourth one denoting the inverse (isPending && !isFetching)? Maybenascentor something? Had a lot of code throughout a project that relied on the status field passed as a prop to downstream components that I was forced to completely refactor sincestatusalone could no longer reflectisLoadingas it did in the original version. At least with two distinct statuses you could cover all bases:status === 'nascent',status === 'loading',['nascent', 'loading'].includes(status). As it stands, the field has been rendered virtually useless in my project and am not even sure of its intended use case any longer over the boolean flags (isLoading,isPending, etc.).All reactions