Skip to content

Commit

Permalink
Mention useStaticQuery hook in documentation (#18920)
Browse files Browse the repository at this point in the history
Adds a mention of the new `useStaticQuery` hook in the Static Query vs. Normal Query documentation. Points users to helpful Gatsby documentation on how to use `useStaticQuery` to query data at build time.
  • Loading branch information
alliestehney authored and GatsbyJS Bot committed Oct 26, 2019
1 parent e6cb313 commit 5a61a1a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/docs/static-vs-normal-queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ title: Static vs Normal Queries
>
> Outdated areas are:
>
> - mention the useStaticQuery hook
> - describe how queries are stripped and JSON imports are rewritten
>
> You can help by making a PR to [update this documentation](https://github.com/gatsbyjs/gatsby/issues/14228).
Expand All @@ -18,8 +17,15 @@ StaticQuery can do most of the things that page query can, including fragments.
- page queries can accept variables (via `pageContext`) but can only be added to _page_ components
- StaticQuery does not accept variables (hence the name "static"), but can be used in _any_ component, including pages
- StaticQuery does not work with raw React.createElement calls; please use JSX, e.g. `<StaticQuery />`
- _NOTE: you can also use the new `useStaticQuery` hook; more information below_
- Static Queries don't need to get run for each page.(ie:Just once)

## useStaticQuery hook

- Gatsby v2.1.0 introduces `useStaticQuery`, a Gatsby feature that allows you to use a React hook to query GraphQL
- `useStaticQuery` is a hook, contrary to `<StaticQuery />` which is a component
- Check out [how to query data at build time using `useStaticQuery`](https://www.gatsbyjs.org/docs/use-static-query/)

### staticQueryComponents

Started here because they're referenced in page-query-runner:findIdsWithDataDependencies.
Expand Down

0 comments on commit 5a61a1a

Please sign in to comment.