7 ms·
No, they are JavaScript, it is array based programming wrapped in a reactive functional-declarative approach. Simply array of objects cascading with state. {#aw
by _hzrk 5y ago
No, they are JavaScript, it is array based programming wrapped in a reactive functional-declarative approach. Simply array of objects cascading with state. {#await promise} is more cryptic than any useHook function implementation.
- dmitriid 5y ago> No, they are JavaScript, it is array based programming wrapped Javascript has no support for array-based programming. So, hooks are not Javascript: they look like regular function calls, but: - they can only be declared and called before rendering - they can't be called out of order - they cannot be called conditionally - they have to be called a specific name to be handled correctly by React runtime - some (but not all of them) require dependency lists that determine how they are invoked > {#await promise} is more cryptic than any useHook function implementation. usEffect documentation is something like 20 pages long. The use of {#await promise} is immediately understandable from the code example, and its entire documentation fits on a page and a half
- Aeolun 5y agoThey are definitely javascript. I can click to definition of the useEffect function and see exactly what it is doing. I completely agree that learning them is a bit crazy, but ultimately every hook comes down to being a function execution.
- dmitriid 5y ago> They are definitely javascript. How come they break Javascript semantics and execution flow? > but ultimately every hook comes down to being a function execution. That's really beside the point when it comes to understand what something is and using them. {#await promise} is immediately understandable from its use. Hooks are... well, I already said above.
- merb 5y ago> How come they break Javascript semantics and execution flow? wait what? since when do they break execution flow and javascript semantics?! useEffect(function () { }); when exactly do you think the function will be called? - correct only the "framework" defines that, but that's completly normal javascript execution and semantic.