fun createElement()

in kotlin-react-legacy/src/jsMain/kotlin/react/ReactElement.ext.kt [5:15]


fun <P : Props> createElement(
    block: Render,
): ReactElement<P>? {
    val nodes = RBuilder().apply(block).childList

    return when {
        nodes.size == 0 -> null
        nodes.size == 1 && isValidElement(nodes.first()) -> nodes.first().unsafeCastToElement()
        else -> createElement(Fragment, children = nodes.toTypedArray()).unsafeCastToElement()
    }
}