[compiler] Fix setState-in-effect for React.useEffect namespace calls (#35377)#35419
Merged
josephsavona merged 1 commit intofacebook:mainfrom Feb 4, 2026
Conversation
|
I was able to confirm that this fixes the issue we were encountering. Thanks! |
Contributor
Author
|
@josephsavona @poteto could you please look into this pull request? |
…facebook#35377) ValidateNoSetStateInEffects treats MethodCall.property as the hook callee (so React.useEffect is detected).\n\nAdds a regression fixture for import * as React with React.useState/React.useEffect.
4bdc04f to
a352ad0
Compare
Member
|
Thanks for the contribution! |
github-actions bot
pushed a commit
that referenced
this pull request
Feb 4, 2026
…#35377) (#35419) ## Summary Fix react-hooks/set-state-in-effect false negatives when Hooks are called via a namespace import (e.g. `import * as React from 'react'` and `React.useEffect(...))`. The validation now checks the MethodCall property (the actual hook function) instead of the receiver object. Issue: Bug: #35377 ## How did you test this change? Added a regression fixture; Ran tests and verified it reports `EffectSetState` and matches the expected output. <img width="461" height="116" alt="Screenshot 2025-12-27 at 14 13 38" src="https://github.com/user-attachments/assets/fff5aab9-0f2c-40e9-a6a5-b864c3fa6fbd" /> DiffTrain build for [22a20e1](22a20e1)
github-actions bot
pushed a commit
that referenced
this pull request
Feb 4, 2026
…#35377) (#35419) ## Summary Fix react-hooks/set-state-in-effect false negatives when Hooks are called via a namespace import (e.g. `import * as React from 'react'` and `React.useEffect(...))`. The validation now checks the MethodCall property (the actual hook function) instead of the receiver object. Issue: Bug: #35377 ## How did you test this change? Added a regression fixture; Ran tests and verified it reports `EffectSetState` and matches the expected output. <img width="461" height="116" alt="Screenshot 2025-12-27 at 14 13 38" src="https://github.com/user-attachments/assets/fff5aab9-0f2c-40e9-a6a5-b864c3fa6fbd" /> DiffTrain build for [22a20e1](22a20e1)
This was referenced Feb 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix react-hooks/set-state-in-effect false negatives when Hooks are called via a namespace import (e.g.
import * as React from 'react'andReact.useEffect(...)). The validation now checks the MethodCall property (the actual hook function) instead of the receiver object.Issue: Bug: #35377
How did you test this change?
Added a regression fixture;
Ran tests and verified it reports
EffectSetStateand matches the expected output.