Код: Выделить всё
import { useState, useEffect } from "react";
export default function Header() {
// States
const [windowWidth, setWindowWidth] = useState(window.innerWidth);
const [menuon, setMenuOn] = useState(false);
// Functions
useEffect(() => {
function handleResize() {
setWindowWidth(window.innerWidth);
}
window.addEventListener("resize", handleResize);
return () => window.removeEventListener("resize", handleResize);
}, []);
function Menu() {
setMenuOn(!menuon);
}
// SVGS
const menusvg = (
);
return (
{/*Menu Ternary for Screen Size*/}
{windowWidth >= 640 ? (
**
More Info
Donate
Email Us
) : (
**
{menusvg}
More Info
Donate
Email Us
)}
);
}Подробнее здесь: https://stackoverflow.com/questions/794 ... or-my-menu
Мобильная версия