Skip to content

Instantly share code, notes, and snippets.

@JoSuzuki
Created September 16, 2021 16:57
Show Gist options
  • Save JoSuzuki/12e2100f3ec4dbbdd9836128feb2b04a to your computer and use it in GitHub Desktop.
Save JoSuzuki/12e2100f3ec4dbbdd9836128feb2b04a to your computer and use it in GitHub Desktop.
[Dont add, subtract] Navbar solution adding
const MyApp = () => {
return (
<div>
<Navbar
items={[
{
label: 'Home',
href: '/home',
},
{
label: 'Products',
href: '/products',
},
{
label: 'Suppport',
onClick: openSupport,
}
{
label: 'About',
href: '/about',
},
]}
/>
<Main />
</div>
);
};
const Navbar = ({ items }) => {
return (
<NavbarStyled>
{items.map(({ href, label, onClick }) =>
href ? (
<Link href={href}>{label}</Link>
) : (
<Button onClick={onClick}>{label}</Button>
),
)}
</NavbarStyled>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment