fable-compiler / fable-react

Fable bindings and helpers for React and React Native
MIT License
275 stars 66 forks source link

Need a consistent way to enter   and other html #192

Closed reinux closed 4 years ago

reinux commented 4 years ago

Currently, the workaround seems to be to do something like this:

let rawHtml html =
  GenericOptions.Empty.AddProp(
    DangerouslySetInnerHTML { __html = html })
    .ToReactElement span

GenericOptions depends on Fulma, and I'm not too sure how else to do this without it.

I think the only reason this is an issue is because I want to inject whitespace between two a elements, and str seems to trim them away.

Zaid-Ajaj commented 4 years ago

Hello @reinux, don't you simply need the DangerouslySetInnerHTML property on any element? i.e.

div [ DangerouslySetInnerHTML  { __html = html } ] 
    [  ] 
reinux commented 4 years ago

Derp. Thanks for that!

MangelMaxime commented 4 years ago

Indeed DangerouslySetInnerHTML that you used in your first snippet is coming from Fable.React

This is actually the expected behaviour.