Skip to content

fix(codegen): accept React.ComponentRef in command first-arg - #3045

Open
ramonclaudio wants to merge 1 commit into
microsoft:mainfrom
ramonclaudio:fix/codegen-accept-componentref-in-commands
Open

fix(codegen): accept React.ComponentRef in command first-arg#3045
ramonclaudio wants to merge 1 commit into
microsoft:mainfrom
ramonclaudio:fix/codegen-accept-componentref-in-commands

Conversation

@ramonclaudio

@ramonclaudio ramonclaudio commented Jul 24, 2026

Copy link
Copy Markdown

Summary

Forward-port of react#54274.

React 19 renamed React.ElementRef to React.ComponentRef, and the TypeScript commands parser here only accepts ElementRef, so a command typed with ComponentRef fails codegen. react-native main already takes both. react-native-macos main and 0.81-stable don't.

It shows up with react-native-screens@4.26, which types a command's first arg as React.ComponentRef<>. ElementRef still works, so nothing that passed before stops passing.

Test plan

Locally yarn jest packages/react-native-codegen passes 2936 tests, and prettier, eslint and yarn flow check are clean.

React 19 renamed `React.ElementRef` to `React.ComponentRef`. The
TypeScript commands parser only accepts `ElementRef`, so a NativeCommand
whose first arg is typed as `React.ComponentRef` fails codegen with "The
first argument of method <name> must be of type React.ElementRef<>".

Forward-ports react#54274 (by Mike Hardy): accept both
names and update the error message. This unblocks libraries that moved to
`ComponentRef`, like react-native-screens 4.26, whose command spec
currently breaks the macOS codegen.
@ramonclaudio
ramonclaudio requested a review from a team as a code owner July 24, 2026 16:14
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@ramonclaudio

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

1 similar comment
@ramonclaudio

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@ramonclaudio

Copy link
Copy Markdown
Author

Mind taking a look? @Saadnajmi @tido64

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant