Open TheBigSasha opened 1 year ago
Q: Why wrap CSS state in React state? A: Using pure CSS improves performance and SSR capabilities, this solution is super friendly to lazy loading in React after the page, because all navbar logic is loaded in HTML and CSS alone, then the heavier Javascript code will react to the CSS state, but only once whatever JS will consume the navbar state is loaded too. Basically, it's for either lighter pages which don't need this hook, or pages using this hook before their js is loaded in to benefit in performance.
Export a hook
useNavbarControl()
which exposes functions that allow you to set and observe the open state of the navbar.To do this
Suggested usage