Advertisement
shadiff

sidebar

Aug 24th, 2023
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. import React from 'react';
  2. import { useLocation } from "react-router-dom";
  3. import "../App.css";
  4. import {SidebarData} from './SidebarData';
  5. import {Link} from "react-router-dom";
  6.  
  7. function Sidebar() {
  8. let location = useLocation()
  9. return (
  10. <div className='Sidebar'>
  11. <ul className="SidebarList">
  12. {SidebarData.map((val, key) => {
  13. return (
  14. <li
  15. key={key}
  16. className="row"
  17. Link to = {`${val.url}`}
  18. id={location.pathname === val.url ? "active" : ""}
  19. onClick={() => {
  20. location.pathname = val.url
  21. }}
  22. >
  23. <div id="icon">{val.icon}</div>
  24.  
  25. <div id="title">{val.title}</div>
  26.  
  27. </li>
  28. )
  29. })}
  30. </ul>
  31. </div>
  32. )
  33. }
  34.  
  35. export default Sidebar
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement