Jordan Petersen
09/09/2024, 8:12 PMkotlin-react-legacy
to kotlin-react
and I got a question about injecting the react app into the dom.
For example we have something like:
main.kt
import react.FC
import react.create
import react.dom.client.createRoot
import web.dom.document
fun main() {
createRoot(document.getElementById("root")!!).render(App.create())
}
private val App = FC {
+"Hello, world!"
}
index.html
<html>
...
<body>
<div id="root"></div>
<body>
</html>
Here web.domdocument.getElementById(...)
and even document.body
returns null, unless i wrap it in a window.onload
is this correct? Seems counter whats in the usage guide so just wondering what I’m missing here?
kotlinReactVersion=18.3.1-pre.799
implementation("org.jetbrains.kotlin-wrappers:kotlin-react:$kotlinReactVersion")
implementation("org.jetbrains.kotlin-wrappers:kotlin-react-dom:$kotlinReactVersion")
implementation("org.jetbrains.kotlin-wrappers:kotlin-react-router-dom:$kotlinReactRouterVersion")
turansky
09/09/2024, 8:35 PMJordan Petersen
09/09/2024, 8:36 PMdocument.body
is null unless i wrap the whole thing in a window.onload
turansky
09/09/2024, 8:38 PMJordan Petersen
09/09/2024, 8:38 PMturansky
09/09/2024, 8:47 PMturansky
09/09/2024, 8:55 PMJordan Petersen
09/09/2024, 9:12 PMJordan Petersen
09/09/2024, 9:12 PM