How can I `render` a class component without `RBui...
# react
m
How can I
render
a class component without
RBuilder
? This is what I'm trying to migrate:
Copy code
fun main() {
    render(document.getElementById("root")) {
        child(App::class) {}
    }
}
1
s
Good question. I still haven't figured out how to use Components since 282. The easiest way to change
App
to a functional component.
Copy code
val App = FC<Props> {
    // Body from old render method here
}
fun main() {
    render(App.create(), document.getElementById("root"))
}
😜 1
👍 1
m
Unfortunately that would be a rather big change for me, so I'd prefer to avoid that 😛
I tried this (after making my
App
class implement
ComponentClass<Props>
):
Copy code
val container = document.getElementById("root") ?: error("Couldn't find root container!")
render(createElement(App(), jso {  }, null), container)
but I get this exception:
Copy code
Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.
oh well, it was worth a try
t
For class component:
Copy code
fun main() {
    render(
        App::class.react.create(),
   document.getElementById("root"),
    )
}
m
thank you once again! 👍