The Power of Curly Braces
In React, JSX is not just a template language; it is a full-powered JavaScript extension. When you wrap code in { }, you are telling React: "Stop reading this as HTML and start executing it as JavaScript."
1. Variable Injection
Any variable currently in scope can be rendered. This includes strings, numbers, and even other JSX elements.
2. Inline Calculations
You can perform operations like {price * 0.8} directly. However, for complex logic, it's better to calculate the value outside the return statement to keep the JSX clean.
3. Conditional Rendering
Since if/else statements don't return a value, they cannot be used inside { }. Instead, we use Ternary Operators or Logical AND (&&).