-
Notifications
You must be signed in to change notification settings - Fork 10.3k
/
wrap-root-element.js
38 lines (36 loc) · 1005 Bytes
/
wrap-root-element.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import React from "react"
import { StaticQuery, graphql, Script } from "gatsby"
import { scripts } from "../gatsby-script-scripts"
import { ContextForSlicesProvider } from "./context-for-slices"
const WrapRootElement = ({ element }) => (
<StaticQuery
query={graphql`
query MetaQuery {
site {
siteMetadata {
title
}
}
}
`}
render={({
site: {
siteMetadata: { title },
},
}) => (
<ContextForSlicesProvider>
{element}
<Script src={scripts.jQuery} strategy="post-hydrate" />
<Script src={scripts.popper} strategy="idle" />
<div>
StaticQuery in wrapRootElement test (should show site title):
<span data-testid="wrap-root-element-result">{title}</span>
<div data-testid="gatsby-browser-hmr">
%TEST_HMR_IN_GATSBY_BROWSER%
</div>
</div>
</ContextForSlicesProvider>
)}
/>
)
export default WrapRootElement