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.

disable hook seems to have wrong true/false logic

See original GitHub issue

Code here means to disable when the result is false, not to disable when the result is true.

if (typeof realm === 'function') {
    return function (hook) {
      const result = realm(hook);
      const update = check => {
        if (!check) {
          throw new errors.MethodNotAllowed(`Calling '${hook.method}' not allowed. (disable)`);
        }
      };
  }

But in docs here it seems to be opposite logic:

  // Disable the remove hook if the user is not an admin
  remove: hooks.disable(function(hook) {
    return !hook.params.user.isAdmin
  })

Either the doc or the code is wrong. I guest it’s the code which is wrong.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
eddyystopcommented, Jan 18, 2017

https://github.com/feathersjs/feathers-hooks-common/pull/108

The disableMethod hook deprecates disable in feathers-hooks-common v3.

1reaction
eddyystopcommented, Jan 17, 2017

I suggest we create another hook that works like disable but with the correct sense. We can wean people away from disable by stressing the new hook in docs and maybe adding a deprecated message.

Any suggestions for the name of the replacement hook?

p.s. I’ve suggested something similar be done with the remove hook which is a no-op for calls made by the server. I’ve suggested delete as the name of that replacement hook.

Read more comments on GitHub >

github_iconTop Results From Across the Web

issue: Uncontrolled disabled checkbox assigned the wrong ...
The first checkbox can have defaultChecked true or false but has to be not disabled.
Read more >
useHooks - Easy to understand React Hook recipes
We bring you easy to understand React Hook code recipes so you can learn how React hooks work and feel more comfortable writing...
Read more >
How to disable button in React.js - Stack Overflow
All of them boils down to disabled="true" that is because it returns true for a non-empty string. Hence, in order to return false...
Read more >
Fallacies | Internet Encyclopedia of Philosophy
Sometimes the term “fallacy” is used even more broadly to indicate any false belief or cause of a false belief. The list below...
Read more >
Conditional Rendering - React
Therefore, if the condition is true , the element right after && will appear in the output. If it is false , React...
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