Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
Bug: eslint-plugin-react-hooks fails handling null chaining operator (react-hooks/immutability) | GoodFirstPicks

Bug: eslint-plugin-react-hooks fails handling null chaining operator (react-hooks/immutability)

facebook/react 2 comments 1mo ago
View on GitHub
mediumopenScope: somewhat clearSkill match: maybeReactJavaScriptTypeScript

Why this is a good first issue

False positive in eslint-plugin-react-hooks requires understanding of rule implementation.

AI Summary

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.

Issue Description

I get a false positive on the react-hooks/immutability rule.

React version: 19.2.0 eslint-plugin-react-hooks version: 7.0.1

Steps To Reproduce

  1. Check example below
  2. Simple removing the ? in line 7 fixes the issue

Link to code example: https://playground.react.dev/#N4Igzg9grgTgxgUxALhAgHgBwjALgAgBMEAzAQygBsCSoA7OXASwjvwFkBPAQU0wAoAlPmAAdOqNxxWYAjFL4AvPihgEAJVJDxk6XVn5cCA8tUIAwmUqUARmTgBrfkKUA+ETtyT5JAHRxYeTpcX1lOSgRfQiYwTEoyTiV8URA6VgQUgG5PAF8AGnwAbQBdQWyJXDMAURISBEZnYUV3MQrdGQJcAAsEAGVccIQkn39AhGCAflCBiPLJSSYSfH4AQm6+mYRheUqYOjmvXHX+waiYuISklJtKCEcs3IKSss8d2DYAHmiAN3wfRWAPhyrgAEghrBB8AB1HCUQgfAD0P1c5Ry4hAeRAehITAA5igQEwALbYPCGTiYIbAfAABUoUFxTDoAHlMMwZPgcvgSDAIET8AByOw2cEAWjiDKZovk9lwoukJKYERgSJiuAFczo-Fa+HwCIRCswSrI7Lo7AgxGQyRAVkoKXEXLAJpiOOMtPpjJZbJY+jKGPAXQgAHcAJLBBB7KxgFDkShqHJAA

The current behavior

Found 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

GitHub Labels

Status: Unconfirmed

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!

Risk Flags

  • eslint-plugin-react-hooks internals
  • null chaining operator handling
Loading labels...

Details

Points10 pts
Difficultymedium
Scopesomewhat clear
Skill Matchmaybe
Test Focusedno