I have a state to keep track when a SubMenu is opened, and toggle it when another Menu Item is clicked. It goes like this:
const [open, setOpen] = useState();
const toggle = (id) => setOpen(id);
onClick={() => toggle(item.navId)}
When I click the refresh button in the browser, the current Sub Menu that is opened, closes. I believe it is because the initial state is empty. How can I keep the current Sub Menu opened after the page is reloaded/refreshed. I've been looking around and I am really not sure if I should use prevState or how to implement it to my case. Any tips or pointing a direction to a solution is much appreciated. Thanks.