React JSX error trying to use Less Than Symbol

I am trying to make a simple button with an arrow point to the left, so I figured I would use the “<“. However when I do

<button><</button>

am I getting an unexpected token error I guess because it thinks I am starting a new element rather than just wanting the < to be the text in the button. Is there anyway around this? Replacing < with “test” compiles and works fine.

Answer

Use the HTML code for less than.

    <button>&lt;</button>

Leave a Reply

Your email address will not be published. Required fields are marked *