Akshay K Nair
Akshay K Nair

Reputation: 1476

What is the difference between {} and ${} in JSX?

The ${} is template literals. What's {} without the $ sign?

In React:

function App(){
    return(<div temp={3}></div>);
}

(I was looking up the difference and nothing came up. So, I think this question is needed as I couldn't know if I was using JS or JSX.)

Upvotes: 3

Views: 4394

Answers (1)

Jamiec
Jamiec

Reputation: 136104

You're quite correct that javascript uses ${} to make use of template literals within strings surrounded by backticks `

The code you pasted is not javascript, it is JSX and the { and } is how you embed expressions within it.

Upvotes: 4

Related Questions