Hooks shouldn't be arrow functions
See original GitHub issueHooks should not return arrow functions because the context (this
) is the surrounding context, not the service (which is being set on normal functions).
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Can I use arrow functions instead of normal ... - Stack Overflow
The short answer is: yes you can. Arrow functions and function declarations/expressions are not equivalent. However, if the function you ...
Read more >Rules of Hooks - React
Don't call Hooks inside loops, conditions, or nested functions. Instead, always use Hooks at the top level of your React function, before any...
Read more >Understanding common frustrations with React Hooks
React Hooks should not be called in nested functions ... An ill-placed arrow function will lead to a useEffect Hook spinning into an ......
Read more >Why do the React docs not use arrow function? - Reddit
Arrow functions are always anonymous which makes it harder to debug. Arrow functions can't be used as a constructor. It is possible to...
Read more >Lifecycle hooks/methods: Add note not to use arrow functions ...
Arrow functions don't work for hook functions and component methods because Vue can't use .bind () on them to bind them to the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’d be more of a consistency thing (also, plain functions might be a little faster since they don’t need to be explicitly bound to another context).
Maybe we should add a
hook.service
? People were confused about whatthis
is in a hook before. It’d be pretty easy to add.daffl has added
hook.service
andhook.path
tofeathers-hooks
.