active classname with hooks

Solutions on MaxInterview for active classname with hooks by the best coders in the world

showing results for - "active classname with hooks"
Bertie
10 May 2016
1const SideBar = () =>{
2  const [activeClass, setClass] = useState('');
3
4  return (
5    <div className="sidebar">
6      <ul>
7        <li> <Link onClick={() => setClass('active')} className={activeClass} to="/"> Home </Link> </li>
8        <li> <Link to="/about"> About </Link> </li>
9        <li> <Link to="/form"> Form </Link> </li>
10      </ul>
11    </div>
12  )
13}
14