'how do I add a dollar sign(before braces) as a string in React?
function Price(props){
<span>This item is ${props.price}</span>
}
I want to use $ as a string, but it doesn't work due to JSX syntax. how can I fix it?
Solution 1:[1]
This code will display '$' as a string, '$' is not a special character in JSX, you may be thinking JQuery
Solution 2:[2]
This should work as is. Also, You could try another approach using template literal syntax:
{`Hello the price is $${price}.`}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | N80 |
| Solution 2 | bnays mhz |
