|
1 | | -import * as React from "react" |
| 1 | +import React, { useContext } from "react" |
2 | 2 |
|
3 | 3 | import Layout from "../components/layout" |
4 | 4 | import Seo from "../components/seo" |
5 | 5 | import * as StaticQuery from "../components/static-query" |
6 | 6 | import * as UseStaticQuery from "../components/static-query/use-static-query" |
| 7 | +import { WrapRootContext } from "../wrap-root-context" |
7 | 8 |
|
8 | | -const StaticQueryPage = () => ( |
9 | | - <Layout> |
10 | | - <h1> |
11 | | - <code>StaticQuery</code> |
12 | | - </h1> |
13 | | - <StaticQuery.ExportedVariable data-testid="exported" /> |
14 | | - <StaticQuery.Variable data-testid="variable" /> |
15 | | - <StaticQuery.Inline data-testid="inline" /> |
16 | | - <h2> |
17 | | - <code>useStaticQuery</code> |
18 | | - </h2> |
19 | | - <UseStaticQuery.Inline data-testid="use-static-query-inline" /> |
20 | | - <UseStaticQuery.Variable data-testid="use-static-query-variable" /> |
21 | | - <UseStaticQuery.ExportedVariable data-testid="use-static-query-exported" /> |
22 | | - <UseStaticQuery.Destructuring data-testid="use-static-query-destructuring" /> |
23 | | - </Layout> |
24 | | -) |
| 9 | +const StaticQueryPage = () => { |
| 10 | + const { title } = useContext(WrapRootContext) |
| 11 | + |
| 12 | + return ( |
| 13 | + <Layout> |
| 14 | + <h1> |
| 15 | + <code>StaticQuery</code> |
| 16 | + </h1> |
| 17 | + <StaticQuery.ExportedVariable data-testid="exported" /> |
| 18 | + <StaticQuery.Variable data-testid="variable" /> |
| 19 | + <StaticQuery.Inline data-testid="inline" /> |
| 20 | + <h2> |
| 21 | + <code>useStaticQuery</code> |
| 22 | + </h2> |
| 23 | + <UseStaticQuery.Inline data-testid="use-static-query-inline" /> |
| 24 | + <UseStaticQuery.Variable data-testid="use-static-query-variable" /> |
| 25 | + <UseStaticQuery.ExportedVariable data-testid="use-static-query-exported" /> |
| 26 | + <UseStaticQuery.Destructuring data-testid="use-static-query-destructuring" /> |
| 27 | + <div> |
| 28 | + StaticQuery in wrapRootElement test (should show site title): |
| 29 | + <span data-testid="wrap-root-element-result">{title}</span> |
| 30 | + </div> |
| 31 | + </Layout> |
| 32 | + ) |
| 33 | +} |
25 | 34 |
|
26 | 35 | export const Head = () => <Seo /> |
27 | 36 |
|
|
0 commit comments