JackTheKnife
JackTheKnife

Reputation: 4144

FontAwesome as a prop for an element

Is there any way to pass FontAwesome as an element prop? I'm trying to do something like

<input
    placeholder={"&#xF002; Search " + searchFor}
/>

but that will display hex code as a string rather than decode to proper font value when it will be as

    placeholder="&#xF002; Search ..."

Any tips on that?

Upvotes: 0

Views: 131

Answers (1)

Nicole
Nicole

Reputation: 1707

You are trying to HTML-encode your UTF-8 symbol, which does not work because React is not HTML (although it looks a lot like it...)

So if you don't use the HTML-encoding but instead the JavaScript encoding "\uF002", your symbol should be displayed the way you want it.

Upvotes: 1

Related Questions