I have a component that should lay out other child...
# react
s
I have a component that should lay out other child components at specific locations. I am currently attempting to pass it in ie.:
Copy code
external interface FieldProps : Props {
  var goalkeeper: ReactNode?
}
FootballField {
   goalkeeper = <what goes here?>
}
However, I cannot find a way to create this component. I expected a function with the a signature like (analogous to the
invoke
from
ChildrenBuilder
):
Copy code
fun <P : Props> createElement(
    type: ElementType<P>,
    block: P.() -> Unit,
): ReactElement<P>
But I cannot find anything other than the quite primitive
createElement
. Is it wrong to pass in components in this way or how should this be done ? I find it hard to believe I am the first with this need Solved: This seems to work:
Copy code
fun <P : Props> ElementType<P>.create(
    block: @ReactDsl P.() -> Unit,
): ReactElement<P>
👍 1