False positive in eslint-plugin-react-hooks requires understanding of rule implementation.
The issue involves a false positive in the eslint-plugin-react-hooks rule when handling the null chaining operator. The fix requires understanding how the rule checks immutability and how it interacts with optional chaining. The scope is somewhat clear but involves internal logic of the plugin.
I get a false positive on the react-hooks/immutability rule.
React version: 19.2.0 eslint-plugin-react-hooks version: 7.0.1
? in line 7 fixes the issueFound 1 error:
Error: This value cannot be modified
Modifying a value previously passed as an argument to a hook is not allowed. Consider moving the modification before calling the hook.
7 | const theStyle = ref.current?.style;
8 | if (!theStyle) return;
> 9 | theStyle.display = "block";
| ^^^^^^^^ `ref` cannot be modi
Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!