What is the replacement for legacy KotlinJS React's RBuilder?

React legacy’s documentation suggested a potential pattern in which extension functions on the RBuilder object are used to make cleaner HTML. The kotlin.xhtml documentation also suggests the same pattern.

With the recent split between react and react-legacy RBuilder no longer exists, replaced with context receivers.

What is the correct way to declare extension functions as before? I.e. To migrate the following example code:

fun RBuilder.box(header: String, block: RDomBuilder<DIV>.() -> Unit) {
	div {
		h5 {+header}

val TestComponent = FC<SomeProps>("TestComponent") {
	box("Title") {
		div { +"Child div..." }

Unfortunately the Kotlin React wrapper has no documentation right now.

1 Like