Skip to content

Commit 70a3bbb

Browse files
authored
chore(develop): Update dev frontend networks requests page for isLoading -> isPending (#12383)
1 parent e2f0dad commit 70a3bbb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

develop-docs/frontend/network-requests.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ type ProjectsListProps = {org: string};
3232

3333
function ProjectsList({org}: ProjectsListProps) {
3434
const {
35-
isLoading,
35+
isPending,
3636
isError,
3737
data: projects,
3838
refetch,
3939
} = useApiQuery<FetchProjectsResponse>(['/projects/', {query: {org}}], {
4040
staleTime: 0,
4141
});
4242

43-
if (isLoading) {
43+
if (isPending) {
4444
return <Placeholder height="100px" />;
4545
}
4646

@@ -112,7 +112,7 @@ export function useFetchProjects(
112112

113113
// ProjectsPage.tsx
114114
function ProjectsPage({orgSlug}: EventsPageProps) {
115-
const {isLoading, isError, data} = useFetchProjects({orgSlug});
115+
const {isPending, isError, data} = useFetchProjects({orgSlug});
116116
return (...)
117117
}
118118

@@ -131,7 +131,7 @@ Note that we add an `options` argument to our `useFetchProjects` hook so that co
131131
- If you know that your data will already be in the cache and you only want to extract the data from it, use this option to prevent rerenders when other `useApiQuery` states change.
132132
- `enabled: <condition>`
133133
- If this query is dependent on information that isn’t available yet, make sure to disable it until you have everything you need.
134-
- Be aware that disabled queries will always return `isLoading: true`! Make sure to account for this in your components with disabled queries.
134+
- Be aware that disabled queries will always return `isPending: true`! In these cases it is often better to use `isLoading` instead, which is the same as `isFetching && isPending`.
135135

136136
Also make note of the function `makeFetchProjectsQueryKey`. We extract out the query key creation to its own function so that consumers of this hook can also update and refetch without having to recreate the query key manually, which can be prone to error.
137137

0 commit comments

Comments
 (0)