Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
Bug: The ESLint react-hooks/immutability rule warns against using a callback internally | GoodFirstPicks

Bug: The ESLint react-hooks/immutability rule warns against using a callback internally

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

Why this is a good first issue

The issue involves a false positive in ESLint's react-hooks/immutability rule.

AI Summary

The issue reports a false positive warning from ESLint's react-hooks/immutability rule when a callback references itself internally. The fix likely requires modifying the rule's logic to handle self-references correctly. The scope is somewhat clear but requires understanding of ESLint and React hooks internals.

Issue Description

eslint-plugin-react-hooks version: 7.0.1

Steps To Reproduce

const Test: FC = () => {
    const onMouseDown = useCallback(() => {
        // warns here about using onMouseDown
        window.removeEventListener('mousedown', onMouseDown);
    }, []);

    useEffect(() => {
        window.addEventListener('mousedown', onMouseDown);

        return () => {
            window.removeEventListener('mousedown', onMouseDown);
        };
    }, [onMouseDown]);

    return <div>Hello</div>;
};

The current behavior

`onMouseDown` is accessed before it is declared, which prevents the earlier access from updating when this value changes over time.

The expected behavior

No errors

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

  • potential false positive
  • requires understanding of ESLint internals
Loading labels...

Details

Points10 pts
Difficultymedium
Scopesomewhat clear
Skill Matchmaybe
Test Focusedno