I noticed createRoot is scoped inside Experimental. It does not look like React considers this API to be experimental; should we move it outside of Experimental?
Good point! ReactDOM apis need to be cleaned up since bindings are having peer dependences>=React@18.x. It needs to be separated to react-dom/client and server too.
Using first-class modules with locally abstract types does not seem to work.
module Select = {
@react.component
let make = (
type a key,
~model as module(T: T with type t = a and type key = key),
~selected: option<key>,
~onChange: option<key> => unit,
~items: array<a>,
) =>
...
}
yields the error:
The type of this packed module contains variables:
module(T with type key = 'type-key with type t = 'type-a)
Thank you for reporting!
This seems not compiled in v3 either. Can you give me a self-contained example?
module Select = {
@react.component
let make = (
type a key,
~model as module(T: T with type t = a and type key = key), // Unbound module type T
~selected: option<key>,
~onChange: option<key> => unit,
~items: array<a>,
) => {
<div />
}
}
Sorry, it just needs some module type T with types t and key. This compiles in v3:
module Select = {
module type T = {
type key
type t
}
@react.component
let make = (
type a key,
~model as module(T: T with type t = a and type key = key),
~selected: option<key>,
~onChange: option<key> => unit,
~items: array<a>,
) => {
<div />
}
}
Thank you for the suggestion! It does work, however, the API becomes rather unwieldy this way as you would have to apply that SomeLib functor separately to every screen component you would like to use.
With React Navigation, it would become extra unwieldy as the API is already quite complex and already requires functors now.
The interface just uses ordinary unification variables, so i think it should be fine. It’d be something like this:
module Select: {
module type T = {
type key
type t
}
@react.component
let make: (
~model: module(T with type t = 'a and type key = 'key),
~selected: option<'key>,
~onChange: option<'key> => unit,
~items: array<'a>,
) => React.element
}