I got this OnClick:
const [open, setOpen] = useState(true);
and
onClick={() => setOpen(!open != true)}
Aim is to "when open then close" and "when closed then remain closed". Above works for the second part but not the first. How to make both my requirements work?
2
Answers
If it is only going to be closed when clicking, then you only need to pass
false
tosetOpen()
I might be getting something confused so please tell me if I am.
Set the onClick method like this:
This will make sure that: