Skip to content

Instantly share code, notes, and snippets.

@PaulieScanlon
Last active January 29, 2022 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PaulieScanlon/1677fefceddbbc35b8083271d1f57616 to your computer and use it in GitHub Desktop.
Save PaulieScanlon/1677fefceddbbc35b8083271d1f57616 to your computer and use it in GitHub Desktop.
Conditional Header
import React, { Fragment } from 'react';
export const wrapPageElement = ({ element, props }) => {
const {
location: { pathname },
} = props
return (
<Fragment>
<header className={`${pathname === '/' ? 'some-class' : 'some-other-class'} `}>
<nav>...</nav>
</header>
<main>{element}</main>
</Fragment>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment