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

chore(docs): Update useStaticQuery example code #18681

Merged
Changes from 1 commit
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: 4 additions & 4 deletions docs/docs/testing-components-with-graphql.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,16 @@ the Header component as:

```jsx:title=src/components/header.js
import React from "react"
import { StaticQuery, graphql } from "gatsby"
import { useStaticQuery, graphql } from "gatsby"

export const PureHeader = ({ data }) => (
<header>
<h1>{data.site.siteMetadata.title}</h1>
</header>
)

export const Header = props => (
const data = useStaticQuery(graphql`
export const Header = props => {
const { data } = useStaticQuery(graphql`
HUFGhani marked this conversation as resolved.
Show resolved Hide resolved
query {
site {
siteMetadata {
Expand All @@ -274,7 +274,7 @@ export const Header = props => (
`)

return <PureHeader {...props} data={data}></PureHeader>
)
}

export default Header
```
Expand Down