spand
09/01/2023, 8:54 AMexternal 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
):
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:
fun <P : Props> ElementType<P>.create(
block: @ReactDsl P.() -> Unit,
): ReactElement<P>