Garmaine Staff asked 1 year ago

I am learning how to use react-burger-menu library and I am having an issue when changing the state to hide the menu. OnClick the links on the menu change the state but it takes two clicks to actually hide the menu. Any ideas what am I doing wrong here?

import React, { useState, useEffect } from "react";
import { Link } from "react-router-dom";
import { slide as Menu } from "react-burger-menu";

const Navbar = () => {
  const [open, setOpen] = useState(false);

  console.log('state of menu:', open)

  return (
         <Menu noOverlay isOpen={open} right>
            <Link to={`/profile/${userId}`} onClick={() => setOpen(!open)}>
             <Link to={`/favorites/${userId}`} onClick={() => setOpen(!open)}>
              Favorite posts
             <Link to="/Settings" onClick={() => setOpen(!open)}>

Thank you in advance for your help!!