Is there way in kotlin javascript compose to embed...
# multiplatform
e
Is there way in kotlin javascript compose to embed browser to show html?
Text is probably not enough
j
Do you mean Compose Web, rendering DOM elements? You can create an element and then set its
innerHTML
e
Aha, thank you, and then I can show/hide it from the kotlin
j
My whole snippet looks like this:
Copy code
@OptIn(ComposeWebInternalApi::class)
@Composable
fun HtmlText(rawHtml: String) {
    val element = document.createElement("div")
    element.innerHTML = rawHtml

    ComposeNode<DomNodeWrapper, DomApplier>(
        factory = { DomNodeWrapper(element) },
        update = {
            set(rawHtml) { value -> (node as Element).innerHTML = value }
        },
    )
}
but it's dated 6 months old so I can't remember (👴) why
innerHTML
is being set twice.
e
Thanks!
Doing a hackathon these days - just launched page on the button click but will try this solution for the nicer follow up.