Skip to content
Advertisement

Render curly braces as plain text in React/JSX

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:

JavaScript

The return (<p>{"{{}}"}<p>) causes

JavaScript

Is there an easy way to escape curly braces in jsx?

Advertisement

Answer

I think the issue is just a typo. You have this:

JavaScript

but you need this (note the closing p tag instead of another opening one):

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement