Rules of hooks

"React relies on the order in which Hooks are called"

Toplevel and unconditionally called

Hooks have to be called in the same order in one component between renders. This allows react to optimize the hooks away (index them away).