Answers for "active classname with hooks"

0

active classname with hooks

const SideBar = () =>{
  const [activeClass, setClass] = useState('');

  return (
    <div className="sidebar">
      <ul>
        <li> <Link onClick={() => setClass('active')} className={activeClass} to="/"> Home </Link> </li>
        <li> <Link to="/about"> About </Link> </li>
        <li> <Link to="/form"> Form </Link> </li>
      </ul>
    </div>
  )
}
Posted by: Guest on January-02-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language