Skip to content

Instantly share code, notes, and snippets.

@anjali1102
Created July 7, 2022 19:15
Show Gist options
  • Save anjali1102/f68e45f531bd5c7bd05c33104bd17f44 to your computer and use it in GitHub Desktop.
Save anjali1102/f68e45f531bd5c7bd05c33104bd17f44 to your computer and use it in GitHub Desktop.
Mapping data from SidebarData.js
import React from "react";
import "./Sidebar.css";
import { SidebarData } from "./SidebarData";
const Sidebar = () => {
return (
<div className="Sidebar">
<ul className="SidebarList">
{SidebarData.map((val, key) => {
return (
<li
key={key}
id={window.location.pathname == val.link ? "active" : ""}
className="listRow"
onClick={() => {
window.location.pathname = val.link;
}}
>
<div id="icon">{val.icon}</div>
<div id="title">{val.title}</div>
</li>
);
})}
</ul>
</div>
);
};
export { Sidebar };
import { GoHome, GoHeart, GoHistory, GoClock, GoPlay } from "react-icons/go";
export const SidebarData = [
{
title: "Home",
icon: <GoHome />,
link: "/",
},
{
title: "Like",
icon: <GoHeart />,
link: "/likes",
},
{
title: "Playlist",
icon: <GoPlay />,
link: "/playlist",
},
{
title: "Watch Later",
icon: <GoClock />,
link: "/watchlater",
},
{
title: "History",
icon: <GoHistory />,
link: "/history",
},
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment