Closed
Description
In addition to the representation described in #96 for foreign components, sometimes it is handy to represent an externally defined component as follows:
bar :: Array Props.Props -> Array React.ReactElement -> React.ReactElement
bar props children = React.createElement barComponent (Props.unsafeFromPropsArray props) children
someBarProp :: String -> Props.Props
someBarProp = Props.unsafeMkProps "someBarProp"
foreign import barComponent:: forall r. React.ReactClass { | r }
In this representation one is able to pass any of the props defined in React.DOM.Props
. This can be useful if the external component forwards props to an underlying DOM element, for example.
However, this representation fails to compile with:
[1/1 NoInstanceFound] src/...
75 bar props children = React.createElement barComponent (Props.unsafeFromPropsArray props) children
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
No type class instance was found for
Prim.Union t1
t2
( key :: String
, ref :: EventHandler (Nullable Ref)
| t0
)
The instance head contains unknown type variables. Consider adding a type annotation.
while applying a function createElement
of type ReactPropFields t0 t1 => ReactClass
{ children :: Children
| t0
}
-> { | t1 } -> Array ReactElement -> ReactElement
to argument barComponent
while inferring the type of createElement barComponent
in value declaration bar
where t1 is an unknown type
t0 is an unknown type
t2 is an unknown type
I am wondering if there is a way to implement this kind of representation or something similar.
//cc @natefaubion
Metadata
Metadata
Assignees
Labels
No labels