Created
January 7, 2021 09:20
-
-
Save timothyde/ba87ae75834d26bacf919f2b879d3610 to your computer and use it in GitHub Desktop.
Header
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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