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

Define HostInstance type for React Native #31101

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yungsters
Copy link
Contributor

@yungsters yungsters commented Sep 30, 2024

Summary

Creates a new HostInstance type for React Native, to more accurately capture the intent most developers have when using the NativeMethods type or React.ElementRef<HostComponent<T>>.

Since React.ElementRef<HostComponent<T>> is typed as React.AbstractComponent<T, NativeMethods>, that means React.ElementRef<HostComponent<T>> is equivalent to NativeMethods which is equivalent to HostInstance.

How did you test this change?

$ yarn
$ yarn flow fabric

Copy link

vercel bot commented Sep 30, 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 Sep 30, 2024 4:56pm


// This validates that INativeMethods and NativeMethods stay in sync using Flow!
declare const ensureNativeMethodsAreSynced: NativeMethods;
(ensureNativeMethodsAreSynced: INativeMethods);

export type HostComponent<T> = AbstractComponent<T, $ReadOnly<NativeMethods>>;
export type HostInstance = NativeMethods;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to make this INativeMethods, but that's going to require its own initiative.

Too many call sites are relying on the ability to spread this type into another object type in order to augment it. (Questionable, but alas… the codebase must grow.)

@react-sizebot
Copy link

react-sizebot commented Sep 30, 2024

The size diff is too large to display in a single comment. The GitHub action for this pull request contains an artifact called 'sizebot-message.md' with the full message.

Generated by 🚫 dangerJS against a0cef2c

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.

3 participants