Skip to content

[compiler] Allow refs in IntersectionObserver callbacks - #36418

Closed
raashish1601 wants to merge 1 commit into
react:mainfrom
raashish1601:codex/refs-intersection-observer
Closed

raashish1601 wants to merge 1 commit into
react:mainfrom
raashish1601:codex/refs-intersection-observer

Conversation

@raashish1601

Copy link
Copy Markdown
Contributor

Summary

The refs lint rule reports a false positive when a ref-reading callback is passed to new IntersectionObserver(...) inside useMemo. The callback is stored by the browser observer and invoked later, not synchronously during render.

This routes NewExpression through the same effect-aware refs validation path used for function calls, then adds a typed IntersectionObserver constructor signature that treats the callback as frozen/read-only. Unknown constructors remain conservative and still report when passed a ref-reading callback.

Fixes #35982

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
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated.

@github-actions github-actions Bot added the Resolution: Stale Automatically closed due to inactivity label Aug 3, 2026
@github-actions

Copy link
Copy Markdown

Closing this pull request after a prolonged period of inactivity. If this issue is still present in the latest release, please ask for this pull request to be reopened. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Resolution: Stale Automatically closed due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: react-hooks/refs false positive using IntersectionObserver

1 participant