Skip to content

[compiler] Fix refs lint false positive for props.ref forwarding#36463

Open
yudin-s wants to merge 1 commit into
facebook:mainfrom
yudin-s:fix-refs-jsx-prop-alias-cla
Open

[compiler] Fix refs lint false positive for props.ref forwarding#36463
yudin-s wants to merge 1 commit into
facebook:mainfrom
yudin-s:fix-refs-jsx-prop-alias-cla

Conversation

@yudin-s
Copy link
Copy Markdown

@yudin-s yudin-s commented May 13, 2026

Summary

Fixes a false positive in the refs validation used by eslint-plugin-react-hooks where forwarding props.ref through JSX could cause sibling props.* reads to be treated as ref accesses.

The ref validation temporary sidemap now keeps ref-typed property loads such as props.ref as their declared ref type instead of aliasing them back to the containing object. This preserves diagnostics for direct props.ref.current updates while allowing ordinary sibling prop reads in JSX.

Adds a compiler fixture covering JSX forwarding of props.ref alongside sibling props.

Fixes #34775

Related: #36416 appears to address the same class of issue; this PR keeps the narrower regression case isolated.

Recreated from #36462 after signing the Meta CLA.

How did you test this change?

  • corepack yarn prettier --check packages/babel-plugin-react-compiler/src/Validation/ValidateNoRefAccessInRender.ts packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/allow-props-property-access-after-ref-prop.tsx
  • node ../snap/dist/main.js test --worker-threads false --pattern allow-props-property-access-after-ref-prop showed 1 Tests, 1 Passed, 0 Failed before the local snap runner shutdown error Farm is ended, no more calls can be done to it
  • node ../snap/dist/main.js test --worker-threads false --pattern error.invalid-write-ref-prop-in-render showed 1 Tests, 1 Passed, 0 Failed before the same local snap runner shutdown error

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.

Bug: eslint-react-hooks false positives on refs rule

1 participant