BestYasuo
BestYasuo

Reputation: 55

How to include ASCII code symbol in React

Is there any way I can include an icon using ASCII code in React. I have done this in HTML and it works just fine, but when thing comes to React it just renders the whole string code

<div class="page-btn">
    <span>1</span>
    <span>2</span>
    <span>3</span>
    <span>4</span>
    <span>&#8594</span> //in html this is a right arrow, in React this is just a plain code
</div>

Upvotes: 0

Views: 3201

Answers (2)

selbie
selbie

Reputation: 104539

Inline a string using javascript unicode escapes. Right arrow is 2192 in Unicode hex. (0x2192 == decimal 8594)

<span>{"\u2192"}</span>

Upvotes: 2

Neetigya Chahar
Neetigya Chahar

Reputation: 693

Please use the ending semi-colon ; for the hex code to get rendered.

example: &#8594;

See CodeSandbox example: Click here

Upvotes: 2

Related Questions