export default function Menu() {
const [menu, setMenu] = React.useState(1);
function toggleMenu() {
setMenu((m) => {
if (m === 3) return 1;
return m + 1;
});
}
return (
<>
<MenuItem menu={menu} />
<button onClick={toggleMenu}>Toggle Menu</button>
</>
);
}
function MenuItem({ menu }) {
switch (menu) {
case 1:
return <Users />;
case 2:
return <Chats />;
case 3:
return <Rooms />;
default:
return null;
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter