From 6845aac5f89d3b59a2f823c0168d6516a007e895 Mon Sep 17 00:00:00 2001 From: pieh Date: Tue, 15 Nov 2022 13:25:48 +0100 Subject: [PATCH] don't output UI in wrapRootElement --- .../src/pages/static-query.js | 45 +++++++++++-------- .../src/wrap-root-element.js | 13 +++--- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/e2e-tests/production-runtime/src/pages/static-query.js b/e2e-tests/production-runtime/src/pages/static-query.js index c9e6c6daa9ea0..4776ed667cfd3 100644 --- a/e2e-tests/production-runtime/src/pages/static-query.js +++ b/e2e-tests/production-runtime/src/pages/static-query.js @@ -1,27 +1,36 @@ -import * as React from "react" +import React, { useContext } from "react" import Layout from "../components/layout" import Seo from "../components/seo" import * as StaticQuery from "../components/static-query" import * as UseStaticQuery from "../components/static-query/use-static-query" +import { WrapRootContext } from "../wrap-root-context" -const StaticQueryPage = () => ( - -

- StaticQuery -

- - - -

- useStaticQuery -

- - - - -
-) +const StaticQueryPage = () => { + const { title } = useContext(WrapRootContext) + + return ( + +

+ StaticQuery +

+ + + +

+ useStaticQuery +

+ + + + +
+ StaticQuery in wrapRootElement test (should show site title): + {title} +
+
+ ) +} export const Head = () => diff --git a/e2e-tests/production-runtime/src/wrap-root-element.js b/e2e-tests/production-runtime/src/wrap-root-element.js index 5ae134cea4168..3a045723a0a2d 100644 --- a/e2e-tests/production-runtime/src/wrap-root-element.js +++ b/e2e-tests/production-runtime/src/wrap-root-element.js @@ -2,6 +2,7 @@ import * as React from "react" import { StaticQuery, graphql, Script } from "gatsby" import { scripts } from "../gatsby-script-scripts" import { ContextForSlicesProvider } from "./context-for-slices" +import { WrapRootContext } from "./wrap-root-context" export default ({ element }) => { return ( @@ -21,13 +22,11 @@ export default ({ element }) => { }, }) => ( - {element} -