<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mikaela Gurney</title>
    <description>The latest articles on DEV Community by Mikaela Gurney (@mikaelia).</description>
    <link>https://dev.to/mikaelia</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F126880%2F19ab0ead-5da5-4ea4-aead-e6535bfbb4a9.jpeg</url>
      <title>DEV Community: Mikaela Gurney</title>
      <link>https://dev.to/mikaelia</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mikaelia"/>
    <language>en</language>
    <item>
      <title>Removing FOUC in a Gatsby App </title>
      <dc:creator>Mikaela Gurney</dc:creator>
      <pubDate>Thu, 11 Jun 2020 21:54:02 +0000</pubDate>
      <link>https://dev.to/mikaelia/removing-fouc-in-a-gatsby-app-28mg</link>
      <guid>https://dev.to/mikaelia/removing-fouc-in-a-gatsby-app-28mg</guid>
      <description>&lt;p&gt;As I've been working more with Gatsby and styled-components, I've run across an issue with flashes of unstyled content showing on page load and refresh in an application deployed to Netlify. Squashing this issue required a bit of exploration.&lt;/p&gt;

&lt;p&gt;Here are the two steps that eventually fixed my problem:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Install the &lt;code&gt;gatsby-plugin-styled-components&lt;/code&gt; &lt;code&gt;styled-components&lt;/code&gt; &lt;code&gt;babel-plugin-styled-components&lt;/code&gt; plugins and update the &lt;code&gt;gatsby-config.js&lt;/code&gt; file (example below). I had only imported &lt;code&gt;styled-components&lt;/code&gt; library, not knowing the other packages were needed.&lt;/p&gt;

&lt;p&gt;This corrected the majority of issues I was having on page refresh. However, the unstyled font flicker was a little tricker to fix. After some experimentation I finally discovered that the &lt;code&gt;gatsby-plugin-typograpy&lt;/code&gt; package did the trick.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Install the &lt;code&gt;gatsby-plugin-typography&lt;/code&gt;, &lt;code&gt;react-typography&lt;/code&gt; and &lt;code&gt;typography&lt;/code&gt; packages and update the &lt;code&gt;gatsby-config.js&lt;/code&gt; (also below) in order to fix font issues.&lt;/p&gt;

&lt;p&gt;This involves creating a &lt;code&gt;src/utils&lt;/code&gt; folder, with a &lt;code&gt;typography.js&lt;/code&gt; file. In order to use Google fonts, the typography file required some configurations.&lt;/p&gt;

&lt;p&gt;Here's mine:&lt;br&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// typography.js

import Typography from "typography"

const typography = new Typography({
  baseFontSize: "18px",
  baseLineHeight: 1.666,
  googleFonts: [
    { name: "Bai Jamjuree", styles: [700] },
    { name: "Muli", styles: [400, 700, 800] },
  ],
  headerFontFamily: ["Muli", "sans-serif"],
  bodyFontFamily: ["Muli", "serif"],
})

export default typography

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Despite not setting the &lt;code&gt;Bai Jamjuree&lt;/code&gt; font to either &lt;code&gt;headerFontFamily&lt;/code&gt; or &lt;code&gt;bodyFontFamily&lt;/code&gt;, I was able to use it elsewhere in my application.&lt;/p&gt;

&lt;p&gt;Here's my &lt;code&gt;gatsby-config.js&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// gatsby-config.js

  plugins: [
    {
      resolve: `gatsby-plugin-styled-components`,
      options: {
        // Add any options here
      },
    },
    {
      resolve: `gatsby-plugin-typography`,
      options: {
        pathToConfigModule: `src/utils/typography`,
      },
    }
  ]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Hope this helps!&lt;/p&gt;

</description>
      <category>gatsby</category>
    </item>
  </channel>
</rss>
