Skip to content

Instantly share code, notes, and snippets.

@timothyde
Created January 7, 2021 09:20
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 timothyde/ba87ae75834d26bacf919f2b879d3610 to your computer and use it in GitHub Desktop.
Save timothyde/ba87ae75834d26bacf919f2b879d3610 to your computer and use it in GitHub Desktop.
Header
import React, { useEffect, useState } from "react";
export default function Header() {
const [small, setSmall] = useState(false);
useEffect(() => {
if (typeof window !== "undefined") {
window.addEventListener("scroll", () =>
setSmall(window.pageYOffset > 200)
);
}
}, []);
return (
<header className={`header ${
small ? "small" : ""
}`}>
Logo etc.
</header>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment