I am trying to figure out what the correct way to ...
# javascript
r
I am trying to figure out what the correct way to use innerHTML - have tried using
dangerouslySetInnerHTML
Copy code
setState{
    itemDescription = props.video.description
        ?.let { webLink.replaceLinks(it) }
        ?.replace("\n", "<br/>")
        ?: ""
}
styledDiv {
    attrs["dangerouslySetInnerHTML"] = state.itemDescription
}
but i dont seem to be able to do:
Copy code
attrs{
    dangerouslySetInnerHTML = state.itemDescription
}
b
Not really a direct answer to your question, but if you want direct access to the DOM element to do tricky stuff like this, then this is a useful pattern that allows you the same level of access you'd have in plain JS.
Copy code
var divDomElement: dynamic
styledDiv {
    ref { divDomElement = it }
}
r
cheers .. actually figured it out after a couple of hours
Copy code
div {
      attrs {
          unsafe {
              +(props.video.description
                            ?.let { webLink.replaceLinks(it) }
                            ?.replace("\n", "<br/>")
                            ?: "")
            }
      }
}
b
Nice! that works!