-
Notifications
You must be signed in to change notification settings - Fork 47.6k
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
||
// 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; |
There was a problem hiding this comment.
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.)
## 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 ``` DiffTrain build for [459fd41](459fd41)
Summary
Creates a new
HostInstance
type for React Native, to more accurately capture the intent most developers have when using theNativeMethods
type orReact.ElementRef<HostComponent<T>>
.Since
React.ElementRef<HostComponent<T>>
is typed asReact.AbstractComponent<T, NativeMethods>
, that meansReact.ElementRef<HostComponent<T>>
is equivalent toNativeMethods
which is equivalent toHostInstance
.How did you test this change?