Displaying a string representing HMTL as actual HTML, not string content in F#'s Fable application

213 Views Asked by At

As the title suggests, I'd like to display a string representing some valid HTML as the actual elements the string represents, not to output the string content.

Example: Given the string This <b>is</b> a <em>string</em> representing HTML, I'd like to see on display: This is a string representing HTML

I asked somewhere else and got an answer about unSafeInsideHTML, a React directive which Fable binds to.
Thing is I've also read online about React's Fragment directive which is said to be safer. I can't, though, understand how to use the Fragment directive from Fable.

So, is using Fragment possible from Fable? If so, how?

1

There are 1 best solutions below

0
On

no idea why wrapping the html elements you're creating in a fragment would make them more secure, but this is how you use Reacts Fragments from F#/Fable.

let view model dispatch =
  fragment [ FragmentProp.Key "some key" ] [ 
    td [ ] [ str "1" ]
    td [ ] [ str "1" ]
    td [ ] [ str "1" ]
  ]