Skip to content

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

Open
Ramon Claudio (ramonclaudio) wants to merge 1 commit into
microsoft:0.81-stablefrom
ramonclaudio:@ramonclaudio/fix-codegen-componentref-0.81
Open

fix(codegen): accept React.ComponentRef in command first-arg#3078
Ramon Claudio (ramonclaudio) wants to merge 1 commit into
microsoft:0.81-stablefrom
ramonclaudio:@ramonclaudio/fix-codegen-componentref-0.81

Conversation

@ramonclaudio

@ramonclaudio Ramon Claudio (ramonclaudio) commented Aug 7, 2026

Copy link
Copy Markdown

Summary

Backport 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 accepts both, but react-native-macos 0.81 does not.

This shows up with react-native-screens@4.26, which types a command's first argument as React.ComponentRef<>. ElementRef still works, so existing command specs continue to pass.

Test plan

  • yarn jest packages/react-native-codegen --watchman=false (66 suites, 2,949 tests, and 1,128 snapshots pass)
  • Prettier check on the modified JavaScript files
  • ESLint on the modified JavaScript files
  • git diff --check origin/0.81-stable...HEAD

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.
@azure-pipelines

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

@ramonclaudio
Ramon Claudio (ramonclaudio) marked this pull request as ready for review August 7, 2026 13:56
@ramonclaudio
Ramon Claudio (ramonclaudio) requested a review from a team as a code owner August 7, 2026 13:56
@azure-pipelines

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

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