Skip to content

[compiler] Allow setState after await in effect callbacks#36417

Open
raashish1601 wants to merge 1 commit intofacebook:mainfrom
raashish1601:codex/set-state-effect-ref-conditionals
Open

[compiler] Allow setState after await in effect callbacks#36417
raashish1601 wants to merge 1 commit intofacebook:mainfrom
raashish1601:codex/set-state-effect-ref-conditionals

Conversation

@raashish1601
Copy link
Copy Markdown

Summary

set-state-in-effect treats callbacks invoked directly by an effect as synchronous. That is correct until an async callback reaches an await: code after that point runs in a later continuation and should not be reported as synchronous setState inside the effect body.

This adds a small must-analysis for async HIR functions to identify instructions that are definitely after an awaited boundary. Calls to a state setter after that point are ignored, while calls before the first await still report.

Fixes #34905

How did you test this change?

  • corepack yarn --cwd packages/eslint-plugin-react-hooks build:compiler
  • corepack yarn --cwd packages/eslint-plugin-react-hooks jest ReactCompilerRuleTypescript-test --runInBand
  • corepack yarn --cwd packages/eslint-plugin-react-hooks typecheck
  • git diff --check

@meta-cla meta-cla Bot added the CLA Signed label May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Compiler Bug]: react-hooks/set-state-in-effect false positive on async function

1 participant