question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hooks shouldn't be arrow functions

See original GitHub issue

Hooks 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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
dafflcommented, Nov 23, 2016

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 what this is in a hook before. It’d be pretty easy to add.

0reactions
eddyystopcommented, Nov 27, 2016

daffl has added hook.service and hook.path to feathers-hooks.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found