Skip to content

Commit

Permalink
Update data-fetching.md
Browse files Browse the repository at this point in the history
  • Loading branch information
hussamkhatib committed Jul 10, 2022
1 parent 3b471e7 commit ee08b3e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions content/docs/data-fetching.md
Expand Up @@ -135,7 +135,7 @@ export default IndexPage
We use `useQuery()` to define a query. Every query has a key for being identify. `react-query` use this key to cache query result data. It means that if user has already queried `getPosts`, the other query with this key in other components will first get the cached data before fetching data again, and then refresh the cache and re-render the UI.
Imagin there are two pages would display posts list. They both have `useQuery('getPosts')`. When user comes to the first page, he will see a loading spinner. But when he navigate to the second page, he will instantly see the posts list without waiting to load because the data was cached.
Imagine two pages that would display the posts list. They both have `useQuery('getPosts')`. When the user comes to the first page, he will see a loading spinner. But when he navigates to the second page, he will instantly see the posts list without waiting to load because the data was cached.
As you can see in the above code example, we can use `isLoading` to know if the HTTP request is loading. And we can use `data` to access to the response data.
Expand Down Expand Up @@ -246,4 +246,4 @@ function onClickAddPost() {
}
```
When the query is marked as stale, `react-query` will refetch all the queries with the `getPosts` key. The UI will be automatically updated with the up-to-date data.
When the query is marked as stale, `react-query` will refetch all the queries with the `getPosts` key. The UI will be automatically updated with the up-to-date data.

0 comments on commit ee08b3e

Please sign in to comment.