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

Model React opaque element types soundly #6753

Closed
2 of 8 tasks
motiz88 opened this issue Aug 17, 2018 · 3 comments
Closed
2 of 8 tasks

Model React opaque element types soundly #6753

motiz88 opened this issue Aug 17, 2018 · 3 comments
Assignees

Comments

@motiz88
Copy link
Contributor

motiz88 commented Aug 17, 2018

Alongside strings, stateless functional components and class components, React currently accepts a set of internal symbols for an element's type (and a few others wrapped in a { $$typeof: ... } object). The symbols themselves are all private; they form "opaque components" that are returned from various public APIs and serve to trigger certain intrinsic behaviours within the renderer.

In Flow, because of limitations in react_kit.ml, we instead model these as function and/or class components, which works in most ordinary cases, but is not technically correct - e.g. Flow will let you call or construct them, which will cause an error at runtime. It would be better if we could leverage opaque types, while keeping props checking and all the other nice things. (Architecturally - perhaps we can allow libdefs to declare these opaque types rather than having to build them directly into react_kit.ml?)

The following is a list of React features based on opaque component types and how they're currently modelled in Flow, if at all.

Stable features

Unstable features

I'm including these for completeness, as they can be expected to officially land in future versions of React. There is no current implementation or PR for these in Flow.

  • unstable_AsyncMode
  • unstable_Profiler
  • Placeholder
@jbrown215
Copy link
Contributor

The machinery necessary for this will be going out in 0.89. This fixes Fragment, StrictMode and forwardRef. I will also take a look at Provider and Consumer.

@jbrown215
Copy link
Contributor

This also fixes Provider and Consumer.

@jbrown215 jbrown215 self-assigned this Dec 3, 2018
@TrySound
Copy link
Contributor

TrySound commented Mar 8, 2019

I guess it's fixed with AbstractComponent.

@TrySound TrySound closed this as completed Mar 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants