Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[compiler] Support enableRefAsProp in jsx transform #31558

Merged
merged 3 commits into from
Nov 18, 2024

Conversation

jackpope
Copy link
Contributor

Since enableRefAsProp shipped everywhere, the ReactElement implementation on prod puts refs on both element.ref and element.props.ref. Here we let the ref case fall through so its now available on props, matching the JSX runtime.

Copy link

vercel bot commented Nov 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 18, 2024 3:39pm

Copy link
Contributor

@josephsavona josephsavona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! One comment to address before landing though

Comment on lines 576 to 582
case 'ref': {
refProperty = {
kind: 'ObjectProperty',
key: {name: 'ref', kind: 'string'},
type: 'property',
place: {...prop.place},
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reusing the object property means reusing the Place instances, which is invalid. let's remove the fallthrough and just assign to both refProperty and push to props with distinct object property values and places

@jackpope jackpope merged commit 4beb1fd into facebook:main Nov 18, 2024
19 checks passed
@jackpope jackpope deleted the ref-as-prop-jsx branch November 18, 2024 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants