Why JSX ?
- It is faster than normal JavaScript as it performs optimizations while translating to regular JavaScript.
- It makes it easier for us to create templates.
- Instead of separating the markup and logic in separate files, React uses components for this purpose. We will learn about components in detail in further articles.
- As JSX is an expression, we can use it inside of if statements and for loops, assign it to variables, accept it as arguments, or return it from functions.
React JSX
React JSX is a syntax extension of JavaScript for writing React Code in a simple way. Using JSX it is easier to create reusable UI components with fewer lines of code in a template-type language with the power of JavaScript.
Table of Content
- What is JSX ?
- Why JSX ?
- Expressions in JSX
- Attributes in JSX
- Specifying attribute values
- Wrapping elements or Children in JSX
- Comments in JSX
- Converting HTML to JSX
- Rules to Write JSX