6

I need to have something like

<p>{</p>
// code
<p>}</p>

How can i use the curly parenthesis without it erroring and say expression needed? Is there an escape character that i can use? i.e. "\""

Strahinja Ajvaz
  • 2,521
  • 5
  • 23
  • 38
  • Does this answer your question? [Render curly braces as plain text react/jsx](https://stackoverflow.com/questions/46614716/render-curly-braces-as-plain-text-react-jsx) – vsync Oct 03 '20 at 11:41

2 Answers2

15

Well, this is a pretty solution. use the same curly brackets for display curly brackets.

 {'{'} {'}'}
Kenry Sanchez
  • 1,703
  • 2
  • 18
  • 24
4

I know there's already plenty of answers but just for completion, I recommend using semantic HTML, in this case I am talking specifically about the code tag (see docs here):

<code>{`{ hello }`}</code>

You can use the backtick to avoid the use of many single or double quotes.

G4bri3l
  • 4,996
  • 4
  • 31
  • 53