News for hackers. Stuff that matters.
Re:React Won by Default – and It's Killing Front End Innovation by b_e_n_t_o_n on Monday September 15, 2025 @08:36PM (#45256670)
Hooks are also just JavaScript functions...?
Re:React Won by Default – and It's Killing Front End Innovation by slmjkdbtl on Monday September 15, 2025 @09:20PM (#45256925)
Based on how they are run they are completely not just ordinary JavaScript functions, hook era components are also not just JavaScript functions, it's a very complicated system. React calling them "just functions" is untrue, just marketing buzz words, and it leads developers into traps.
Re:React Won by Default – and It's Killing Front End Innovation by b_e_n_t_o_n on Monday September 15, 2025 @10:13PM (#45257274)
Many functions can only be called in a certain context. Calling them "not functions" is misleading imo because it implies those functions are compiled out or something, like `$state()` in Svelte.
Re:React Won by Default – and It's Killing Front End Innovation by slmjkdbtl on Monday September 15, 2025 @10:23PM (#45257348)
Yeah they themselves are functions but how they're called are managed by a complicated system, I think treating them as a separate new concept is less misleading than calling them plain functions
Re:React Won by Default – and It's Killing Front End Innovation by b_e_n_t_o_n on Monday September 15, 2025 @11:46PM (#45257835)
Well they aren't plain functions, they're like lifecycle methods for the component with an implicit `this`. Perhaps that's how they should be described.
Re:React Won by Default – and It's Killing Front End Innovation by Izkata on Tuesday September 16, 2025 @07:59AM (#45261051)
> React calling them "just functions" is untrue

I'm pretty sure this is also untrue. AFAIK React has never used that phrase (and at the very least, I can't find it anywhere official right now), it came from other people convincing newcomers that hooks aren't something more complicated like objects (comparing to class-based components). React has always treated them as special functions, hence always prefixing them with the word "use".

Re:React Won by Default – and It's Killing Front End Innovation by slmjkdbtl on Tuesday September 16, 2025 @10:54AM (#45263147)
> it came from other people convincing newcomers

Yeah I think you're right

Re:React Won by Default – and It's Killing Front End Innovation by thomasfromcdnjs on Monday September 15, 2025 @08:59PM (#45256801)
They kind of are not though, you can't call them out of order and other things which is checked at runtime by the React "engine" and will stop script execution. If they were regular functions you could call them anytime.
Re:React Won by Default – and It's Killing Front End Innovation by b_e_n_t_o_n on Monday September 15, 2025 @10:14PM (#45257276)
Many "regular" functions are context dependent.
Re:React Won by Default – and It's Killing Front End Innovation by DangitBobby on Monday September 15, 2025 @11:18PM (#45257679)
They are context dependent, must execute in the same order every time, and must be called every time the component re-renders (i.e., they do not support conditional calls). They have enough gremlin rules that calling them "just functions" is unhelpful for reasoning about using them.