0

What is meant by {" "} in React JSX? I see it in the code below:

 <p><a href="/" className="mx-1">Home</a> {" "}| {" "} <a className="mx-1" href="/about-us">About 
 Us</a> {" "}|{" "}<a className="mx-1" href="/terms">Terms</a></p>
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
johnmadta
  • 57
  • 4

3 Answers3

2

{} is used to interpolate JavaScript inside your JSX.

Using {' '}is used to insert a space inside your JSX while avoiding any side effet. Using this to insert a space does not insert any HTML tag in your code.

See: Best practice when adding whitespace in JSX

Clafouti
  • 4,035
  • 5
  • 30
  • 38
0

It is one of the ways of adding additional spaces.

radulle
  • 1,437
  • 13
  • 19
0

When you want to add JavaScript inside your JSX, you need to use {}

To add a space {' '} can be used. But generally, the prettier converts some spaces in the editor into {' '}.

msahin
  • 1,520
  • 1
  • 16
  • 22