Skip to content

Commit

Permalink
docs: use NetworkStatus enum rather than numbers (#6200)
Browse files Browse the repository at this point in the history
  • Loading branch information
glenwinters committed May 19, 2020
1 parent 3b6aff1 commit a18ee7e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions docs/source/data/queries.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ of this information, we need to set the `notifyOnNetworkStatusChange` option to
<div data-language="hooks-js">

```jsx:title=index.js
import { NetworkStatus } from '@apollo/client';

function DogPhoto({ breed }) {
const { loading, error, data, refetch, networkStatus } = useQuery(
GET_DOG_PHOTO,
Expand All @@ -339,7 +341,7 @@ function DogPhoto({ breed }) {
},
);

if (networkStatus === 4) return 'Refetching!';
if (networkStatus === NetworkStatus.refetch) return 'Refetching!';
if (loading) return null;
if (error) return `Error! ${error}`;

Expand All @@ -356,6 +358,8 @@ function DogPhoto({ breed }) {
<div data-language="js">

```jsx:title=index.js
import { NetworkStatus } from '@apollo/client';

const DogPhoto = ({ breed }) => (
<Query
query={GET_DOG_PHOTO}
Expand All @@ -364,7 +368,7 @@ const DogPhoto = ({ breed }) => (
notifyOnNetworkStatusChange
>
{({ loading, error, data, refetch, networkStatus }) => {
if (networkStatus === 4) return 'Refetching!';
if (networkStatus === NetworkStatus.refetch) return 'Refetching!';
if (loading) return null;
if (error) return `Error! ${error}`;

Expand All @@ -385,7 +389,7 @@ const DogPhoto = ({ breed }) => (
</div>
</MultiCodeBlock>

The `networkStatus` property is an enum with number values from `1` to `8` that represent different loading states. `4` corresponds to a refetch, but there are also values for polling and pagination. For a full list of all the possible loading states, check out the [source](https://github.com/apollographql/apollo-client/blob/master/src/core/networkStatus.ts).
The `networkStatus` property is a `NetworkStatus` enum that represents different loading states. Refetch is represented by `NetworkStatus.refetch`, and there are also values for polling and pagination. For a full list of all the possible loading states, check out the [source](https://github.com/apollographql/apollo-client/blob/master/src/core/networkStatus.ts).

## Inspecting error states

Expand Down

0 comments on commit a18ee7e

Please sign in to comment.