Render curly braces as plain text in React/JSX

前端 未结 3 428
再見小時候
再見小時候 2020-12-06 16:13

I am having problems displaying { and } as text in React. I saw a similar question that someone said to wrap the entire string in curlies, but this is not working:



        
3条回答
  •  日久生厌
    2020-12-06 16:37

    You can even use string interpolation in ES6. Template literals are string literals allowing embedded expressions. You can use multi-line strings and string interpolation features with them. Template literals are enclosed by the backtick () (grave accent) character instead of double or single quotes.

    eg: return (

    {`{{}}`}

    )

提交回复
热议问题