2 ms·
Alright, weird semantics then. The hooks calls are unusual compared to normal Javascript code. If you read the other comments on this thread you'll see that I'
by beaconstudios 8y ago
Alright, weird semantics then.
The hooks calls are unusual compared to normal Javascript code. If you read the other comments on this thread you'll see that I'm not the only one saying that. It comes down to the fact that it's a call, inside a render function, that has different behaviour on each call to said parent function. It's very magical - and the React team admit that, so I'm not sure what exactly you are arguing against.
It's not like I'm new to Javascript either - I've been coding in JS for over 10 years. I understand how it works, but it's still weird-looking code. You can hack up the language to make stuff like the new hooks library, even without the unique quirks of React's internals. But libraries that intentionally do that to generate magical effects are generally considered "weird" too.
- WorldMaker 8y agoI appreciate something about it feels weird to a number of people, and it feels that way to me at times, too. I'm just pointing out: In JS call order always matters (it's an imperative language full of side effects), and many calls have side effects that very much differ based on the order you call them. Even if the gut reaction to hooks is that they "feel" magical or quirky, it's not that different from how a lot of black box function calls already work in the language, it's just maybe more obvious with hooks because they are more explicit in the rules on when you should call them. Which isn't to denigrate feeling weird about hooks. Again, even I still feel weird about them sometimes. Just that it is less unusual than that initial gut reaction seems to think it is.