We have run into issue coming from calling hooks from class component, I was surprised that eslint rules doesn't provide any check for that. Is there any reason for that? Am I missing something? I willing to contribute in case this feature request will be approved. 馃檶
eslint-plugin-react-hooks version: 2.3.0
Link to code example: https://codesandbox.io/s/rules-of-hooks-class-tr0ko
There is currently no check for class token. You can use hook within method of your class without triggering any warning coming from Rule of Hooks rules.
The usage of hooks within class should be restricted since it's against
As per es-lint-rules-hooks
// Ignore class methods for now because they produce too many
// false positives due to feature flag checks. We're less
// sensitive to them in classes because hooks would produce
// runtime errors in classes anyway, and because a use*()
// call in a class, if it works, is unambiguously *not* a hook.
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!
Recent versions will check hooks in component class.
Most helpful comment
As per es-lint-rules-hooks