Q2: What is JSX and why do we use it in React?
JSX (JavaScript XML) is a syntax extension for JavaScript that allows developers to write HTML-like markup directly inside JavaScript files. Compilers like Babel transform JSX syntax into standard React.createElement() function calls at compile time.
Key Takeaways
- JSX allows writing component structure and rendering logic in a visual, declarative syntax.
- Babel transpiles JSX tags into standard
React.createElement()function calls.
Knowledge Check
What does JSX transpile to under the hood?