Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions develop-docs/frontend/network-requests.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ type ProjectsListProps = {org: string};

function ProjectsList({org}: ProjectsListProps) {
const {
isLoading,
isPending,
isError,
data: projects,
refetch,
} = useApiQuery<FetchProjectsResponse>(['/projects/', {query: {org}}], {
staleTime: 0,
});

if (isLoading) {
if (isPending) {
return <Placeholder height="100px" />;
}

Expand Down Expand Up @@ -112,7 +112,7 @@ export function useFetchProjects(

// ProjectsPage.tsx
function ProjectsPage({orgSlug}: EventsPageProps) {
const {isLoading, isError, data} = useFetchProjects({orgSlug});
const {isPending, isError, data} = useFetchProjects({orgSlug});
return (...)
}

Expand All @@ -131,7 +131,7 @@ Note that we add an `options` argument to our `useFetchProjects` hook so that co
- 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.
- `enabled: <condition>`
- If this query is dependent on information that isn’t available yet, make sure to disable it until you have everything you need.
- Be aware that disabled queries will always return `isLoading: true`! Make sure to account for this in your components with disabled queries.
- 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`.

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.

Expand Down
Loading