disable hook seems to have wrong true/false logic
See original GitHub issueCode 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:
- Created 7 years ago
- Comments:16 (9 by maintainers)
Top 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 >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
https://github.com/feathersjs/feathers-hooks-common/pull/108
The
disableMethod
hook deprecatesdisable
in feathers-hooks-common v3.I suggest we create another hook that works like
disable
but with the correct sense. We can wean people away fromdisable
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 suggesteddelete
as the name of that replacement hook.