- These are "just function calls"
- Except they are "iterators"
- Except if you have them in a conditional, you must provide an `else` branch so that `next` is called the same number of times
None of this is in the semantics of the language where I don't have to provide an else branch to an iterator, and function calls are not iterators ;)
* React stores the state for your hooks in a list which is iterable.
* useBlah is just a normal function that internally calls next() on that list to get the next hook state which is why order matters.
* React checks that the iteratior on the list is at the end to see if you’ve consumed all the hooks and throws an error if not because it’s indicative of a bug in your code.
Like at this point the only thing I can recommend is try writing a toy implementation of hooks and see that they’re not magic, they’re just normal JS, and that the restrictions flow naturally from the implementation.
Like why do you want so bad for hooks to be weird?
you keep showing isn't a normal function :)
> Like why do you want so bad for hooks to be weird?
I don't want them to be weird. They are weird already. https://news.ycombinator.com/item?id=30801466