Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mention useStaticQuery hook in documentation #18920

Merged
merged 2 commits into from
Oct 26, 2019
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: 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