Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
Bug: eslint(react-hooks/set-state-in-effect) not work with try catch function | GoodFirstPicks

Bug: eslint(react-hooks/set-state-in-effect) not work with try catch function

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

Why this is a good first issue

ESLint rule behavior inconsistency with try/catch/finally blocks.

AI Summary

The issue involves inconsistent behavior of the ESLint rule `react-hooks/set-state-in-effect` when state updates are inside `useEffect` with `try/catch/finally` blocks. The rule fails to report errors in certain configurations, suggesting a gap in control-flow analysis. The problem appears to be related to ESLint's internal logic rather than React itself, making it unclear if this is a React-specific issue.

Issue Description

React version: 19.2

Steps To Reproduce

Image

Link to code example:

const Demo = ()=>{
  const [count, setCount] = useState(0);
  useEffect(()=>{
    setCount(123);
  },[])
  const handleClick = useCallback(()=>{
    try {
      console.log("do");
    } catch (_error) {
      console.log("error");
    }finally{
      console.log("finally");
    }
  },[])
  return <div onClick={handleClick}>Demo {count}</div>
}

const Demo2 = ()=>{
  const [count, setCount] = useState(0);
  useEffect(()=>{
    setCount(123);
  },[])
  
  return <div>Demo {count}</div>
}

The current behavior

eslint not work

The expected behavior

eslint work

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 configuration ambiguity
  • control-flow analysis complexity
Loading labels...

Details

Points10 pts
Difficultymedium
Scopesomewhat clear
Skill Matchmaybe
Test Focusedno