How do you render HTML entities to the DOM using ReasonML/ReasonReact?
HTML Entities in ReasonML/ReasonReact
It looks like this works for only a certain set of characters at the moment. I was trying to create menu bars:
Ah, I have to use dangerouslySetInnerHTML={{ "__html": "☰" }}. Didn’t want to have to do that but oh well.
I don’t see why that wouldn’t work with just Unicode, but yeah if you have to emit actual HTML entities then you have to wrap it in another element.
This is an issue with React, not Reason or ReasonReact, btw, so other solutions might be, or become, possible if React enables them.
You can usually avoid dangerouslySetInnerHTML by putting the actual Unicode character in the rendered text, e.g. the literal ☰ glyph for the trigram/menu symbol. React will escape and display it as text; the entity syntax only matters when your source or data must remain ASCII HTML. If the value genuinely arrives as an entity string, dangerouslySetInnerHTML remains the straightforward escape hatch.
its basically the same escaping bug as in that gas story where < became < https://newscrawler.org/en/e/gas-getcontent-escapes-raw-js-breaks-embedded-libraries/ so sticking with unicode avoids it unless the data forces entities on you.