-
I am not sure if this is an issue or expected behaviour, hence creating under discussion to avoid polluting the issues section. Application Structure:I have a nav bar with 3
The main layout is pretty straightforward: import { Link } from "gatsby";
import React from "react";
import "./Layout.css";
export const Layout = ({ children }) => {
return (
<div className="page-container">
<nav className="nav">
<Link className="link" activeClassName="active" to="/">
Home
</Link>
<Link className="link" activeClassName="active" to="/about/">
About
</Link>
<Link className="link" activeClassName="active" to="/contact/">
Contact
</Link>
</nav>
<main className="main">{children}</main>
<footer className="footer">A Simple Gatsby Site</footer>
</div>
);
}; Since this is a Layout, I use it in import React from "react";
import { Layout } from "./src/components/Layout";
// Wraps every page in a component
export const wrapRootElement = ({ element, props }) => {
return <Layout {...props}>{element}</Layout>;
}; Problem:Initial page load is fine. Screen.Recording.2021-05-23.at.10.48.51.AM.movSteps to replicate:
Questions:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Another quick observation, when I run // public/about/index.html
<nav class="nav">
<a aria-current="page" class="link active" href="/">Home</a>
<a class="link" href="/about/">About</a>
<a class="link" href="/contact/">Contact</a>
</nav> To replicate, run Now I'm inclined to think this is a bug? |
Beta Was this translation helpful? Give feedback.
-
I can't believe that the fix was as simple as: // Wraps every page in a component
- export const wrapRootElement = ({ element, props }) => {
+ export const wrapPageElement = ({ element, props }) => {
return <Layout {...props}>{element}</Layout>;
}; Another symptom of skimming the docs, instead of actually reading it. I am so dumb 🤦🏽 https://www.gatsbyjs.com/docs/reference/config-files/gatsby-browser/#wrapPageElement |
Beta Was this translation helpful? Give feedback.
I can't believe that the fix was as simple as:
Another symptom of skimming the docs, instead of actually reading it. I am so dumb 🤦🏽 https://www.gatsbyjs.com/docs/reference/config-files/gatsby-browser/#wrapPageElement