1

I have a line in my view like this:

return (<Button title='&#9654;' />)

which works to display the "arrow forward" ▶ symbol.

While trying to clean it up, I tried to do something like this:

let arrowRight = '&#9654;';
return (<Button title={arrowRight} />)

But now it displays the button with a title of &#9654;

As an alternative, I've just put the actual unicode symbol in there and made sure the document is UTF-8 and it works fine. But it made me curious.

Is there a simple way to tell React not to html encode the string?

Ulysse BN
  • 10,116
  • 7
  • 54
  • 82
ben
  • 488
  • 3
  • 11
  • This might be the solution you're looking for: https://stackoverflow.com/questions/35166758/react-javascript-displaying-decoding-unicode-characters – Eric Nov 14 '18 at 14:33
  • This is not an *attribute* but a *prop*. A simple way is to not use HTML entity in the first place, `let arrowRight = '▶';` – Estus Flask Nov 14 '18 at 14:57

0 Answers0