You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[flow][ref-as-prop] Make React.ComponentType's ref prop behave like ref?: empty
Summary:
This diff continues to make progress to move towards full support for ref-as-prop instead of staying in the current half-done state where the ref prop is still too special.
In this diff, we aim to make `React.ComponentType<{}>` behave like `component(ref?: empty)` for subtyping. `React.ComponentType<...>` is always supposed to be the top type in terms of component instance. Previously before ref-as-prop, it behaves like `component(ref?: React.RefSetter<mixed>)` because the ref prop is special and it's always a ref-setter, but with ref-as-prop, it should be the same as all other props, similar to how `React.ComponentType<empty>` is the top type of all components.
I was able to make the change for most of the subtyping rule, except for the `React.ComponentType<{}> ~> component(ref: ref_prop)` one because the error diff is too big (see D69706346) and we cannot fix the codebase without this diff as a pre-req. This is relatively harmless, because ref-prop is still kinda special. But once a new Flow version with this diff is deployed, we will be able to start replacing most of the generic `component(ref: React.RefSetter<GenericInstance>, ...Props)` with `component(ref: GenericRefProp, ...Props)` so that we can continue the rollout.
Changelog: [internal]
Reviewed By: jbrown215
Differential Revision: D69706347
fbshipit-source-id: 8c8f2ebad492f9ba8e8e2dead6c8b253a8e2ba84
0 commit comments