Skip to content

Commit

Permalink
(#7278): distinct heading levels for sections
Browse files Browse the repository at this point in the history
  • Loading branch information
amberleyromo committed Aug 13, 2018
1 parent f74df65 commit 1542bbd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions docs/docs/static-query.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ title: Querying data in components using StaticQuery

Gatsby v2 introduces `StaticQuery`, a new API that allows components to retrieve data via GraphQL query.

In this guide, we'll walk through an example using `StaticQuery`, and discuss [the difference between a StaticQuery and a page query](/static-query/#how-staticquery-differs-from-page-query).
In this guide, we'll walk through an example using `StaticQuery`, and discuss [the difference between a StaticQuery and a page query](/static-query/#how-staticquery-differs-from-page-query).

## Basic example
## How to use `StaticQuery` in components

### Basic example

We'll create a new `Header` component located at `src/components/header.js`:

Expand Down Expand Up @@ -38,7 +40,7 @@ export default Header

Using `StaticQuery`, you can colocate a component with its data. No longer is it required to, say, pass data down from `Layout` to `Header`.

## Typechecking
### Typechecking

With the above pattern, you lose the ability to typecheck with PropTypes. To regain typechecking while achieving the same result, you can change the component to:

Expand Down

0 comments on commit 1542bbd

Please sign in to comment.