A Visual Guide to React Mental Models: UseState, UseEffect and Lifecycles
While equivalent to a proper approach, it feels like hooks are an unnecessary hack.What could be done is to have the component function return a closure that returns the VDOM nodes instead of the VDOM nodes themselves, and then the hooks would be run only once, since rerendering would only run the returned closure and not the whole component function, and there would be no need  for the magic or rules.Like this:  const Component = component((comp) => {
    const [show, setShow] = useState(comp, false);

    return (...props) => (
      
         setShow(!show())}>Show Menu
        // Mounted with show = true and unomunted with show = false
        {show() && }
      
    );
  });

Where the changes are that the hook takes the component as an argument, show is now a function rather than a value and a closure (that takes the props) is returned rather than returning the VDOM nodes directly.The React Hooks API is essentially equivalent to this, but inelegant, unintuitive and somewhat inefficient.