Skip to content

fix: onRenderBody into gatsby-browser 😺👍 #22

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

olavea
Copy link
Owner

@olavea olavea commented Dec 9, 2021

fix: onRenderBody into gatsby-browser 😺👍 #23

// gatsby-browser.js 😺👍
import React from 'react';
import Layout from './src/components/Layout';
import { onRenderBody } from "./gatsby-ssr";

export function wrapPageElement({ element, props }) {
  return <Layout {...props}>{onRenderBody, element}</Layout>;
}

and

😺👍
// gatsby-ssr.js
import React from "react";
import Layout from "./src/components/Layout";

const OusetaScriptComponent = () => {
  return (
    <script
      key="outseta-script"
      id="outseta-script"
      src="https://cdn.outseta.com/outseta.min.js"
      data-options="o_options"
    />
  );
};

const OusetaConfigComponent = () => {
  const config = {
    domain: "queen.outseta.com",
    monitorDom: true,
  };
  return (
    <script
      key="outseta-config"
      id="outseta-config"
      dangerouslySetInnerHTML={{
        __html: `var o_options = ${JSON.stringify(config, null, 2)}`,
      }}
    />
  );
};



// B. Body setHead on body

const onRenderBody = ({ setHeadComponents }) => {
  return setHeadComponents([OusetaConfigComponent(), OusetaScriptComponent()]);
};


export function wrapPageElement({ element, props }) {
  return <Layout {...props}>{onRenderBody, element}</Layout>;
}

@olavea olavea self-assigned this Dec 9, 2021
@gatsby-cloud
Copy link

gatsby-cloud bot commented Dec 9, 2021

Gatsby Cloud Build Report

TimeShip-1

🎉 Your build was successful! See the Deploy preview here.

Build Details

View the build logs here.

🕐 Build time: 1m

Performance

Lighthouse report

Metric Score
Performance 💚 92
Accessibility 💚 92
Best Practices 💚 100
SEO 🔶 66

🔗 View full report

@olavea olavea requested a review from raae December 9, 2021 08:43
@olavea
Copy link
Owner Author

olavea commented Dec 9, 2021

Hey @raae

This works for me, but what does it do?
No don't answer that, I'll look into it later.

So give me some pointers in what direction to look. Here are some ideas:
-My performance went up from ... to ... se screenshots below
-Am I doing 1 thing with gatsby-ssr that happens "right away" for Lillian (6 🏴‍☠️ 👸 ) and doing another thing gatsby-browser that happens "later" for Lillian (6 🏴‍☠️ 👸 )?
-Where can I "see" the results of what I did here?

  1. In the "inspect" in my browser?
  2. with a console log?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant