Skip to content

Conversation

@mikehardy
Copy link
Contributor

Summary:

React v19 deprecated React.ElementRef and recommends using React.ComponentRef

This appears to work just fine, with no other changes other than the type, with the exception of the Codegen phase which makes no allowance for ComponentRef during parsing

I altered the typescript and flow parsers to accept the new ComponentRef as well as the old ElementRef

Changelog:

[INTERNAL][DEPRECATED] - use React.ComponentRef in codegen in place of React.ElementRef

Test Plan:

This is mostly checked in jest tests, I updated the fixtures to send ComponentRef through, and I updated the snapshots to expect a message that indicates either ElementRef or ComponentRef are expected

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 25, 2025
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Oct 25, 2025
@mikehardy mikehardy force-pushed the ElementRef-becomes-ComponentRef branch from 7e9c966 to af65324 Compare October 25, 2025 20:27
@mikehardy
Copy link
Contributor Author

There was a linting error in my diff, I fixed that and re-pushed.

The android build error is some deprecation warnings while -Werror is passed, not part of this PR

Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

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

Thanks @mikehardy for fixing this!

@meta-codesync
Copy link

meta-codesync bot commented Oct 27, 2025

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this in D85556329.

@javache
Copy link
Member

javache commented Oct 27, 2025

I believe the ComponentRef changes are specific to TypeScript, so no code under flow should be changed. Flow does not have a React.ComponentRef https://flow.org/en/docs/react/types/

@mikehardy
Copy link
Contributor Author

@javache oh interesting! I am unfamiliar with flow types and assumed they would be similar, I'll focus this change on typescript when I get a chance / removing the flow bits then and re-push. Thanks for catching that

- Note Typescript has this chance, Flow does not have ComponentRef type,
  so this is typescript-only and Flow did not need a similar change
@mikehardy mikehardy force-pushed the ElementRef-becomes-ComponentRef branch from af65324 to 4271a9c Compare October 27, 2025 15:10
@mikehardy
Copy link
Contributor Author

Okay, @cipolleschi - after Pieter's astute observation that this should be typescript-only since Flow does not have a corresponding change, I have re-pushed this with changes only to the typescript codegen parser + test fixtures + test snapshots. I believe that means you need to reimport?

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. sony

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codegen strictly requires deprecated React.ElementRef vs recommended React.ComponentRef

4 participants