This is the third article in ReactJS – Zero to Hero Series. I will recommend reading the first two articles (link given below), before going through this article.
In this article, we will see what is JSX and its features. We will also see how to Render Elements in React.
JSX is an external, domain-specific language that is optimized for generating XML-like documents. For a React application, JSX will typically be used to generate HTML, but it also supports custom React components and SVG.
- We can embed any JavaScript expression in JSX by wrapping it in curly braces.
- JSX is a language, which works like a JavaScript extension hence the name JSX.
- JSX does optimization while compiling the code to JavaScript. The generated code runs quicker than a similar code written in JavaScript
- As compared to JavaScript, JSX is statically typed and type safe. The quality of applications is better when built using JSX since errors are caught early and quickly.
- JSX provides object-oriented features similar to Java or C++, which is very different from primitive prototypal inheritance approach defined by JavaScript.
A very simple JSX expression is shown below. The statement is neither a string nor HTML.
- const element = <h1>Hello, world!</h1>;
JSX Attribute Expressions (Specifying Attributes with JSX)
To supply props to a React component, we specify attributes on the JSX element. Consider the below JSX expression.

- Hello is the JSX element name and the corresponding React element.
- now is the JSX attribute that will populate the now prop on the React component.
- The value assigned to the new attribute is a JSX attribute expression. The expression inside the curly braces can be any valid JavaScript expression.
When the component is rendered, the JavaScript expression will be evaluated and supplied as the value for the new prop on the Hello component. JSX attributes can also be given a literal string by using quotes instead of curly braces.
- const element = <div tabIndex="0"></div>;
Child Expressions (Specifying Children with JSX)
JSX is hierarchical, so any valid JSX expression may be a child of any other JSX expression. We can have many JSX expressions, or elements, within a single JSX component. That is, a JSX expression can have multiple direct children.
Within components, you can reference JSX child elements via the special property – this.props.children




Hamid KhanPosted Sep 29, 2017, 9:37 AM
Nice.............................................