ReactJs : Tutorial-02-JSX
What is JSX?
 JSX is an extension to javascript.
 It is a template script where you will have the power of using HTML and Javascript
together.
Here is a simple example of a JSX code.
const h1tag = "<h1>Hello, from RTDL Tutorials!</h1>";
Why we need JSX in React?
For a UI, we need Html, and each element in the DOM will have events to be handled, state
changes, etc.
In case of React, it allows us to make use of Html and javascript in the same file and take care
of the state changes in the DOM in an efficient manner.
Expressions in JSX
index.js
import React from 'react';
import ReactDOM from 'react-dom';
ReactDOM.render(
<h1>Hello, from RTDL Tutorials!</h1>,
document.getElementById('root')
);
index.js
import React from 'react';
import ReactDOM from 'react-dom';
const display = "Hello, from RTDL Tutori
als!";
const h1tag = "<h1>{display}</h1>";
ReactDOM.render(
h1tag,
document.getElementById('root')
);
The Output will show the line as
ReactJs : Tutorial-02-JSX
What is the solution of this?
Create a text.jsx file and put the code in the file.
Import the test.jsx file in to index.js file and use it.
test.jsx
import React from 'react';
import ReactDOM from 'react-dom';
const display = "Hello, to RTDL Tutorial
s";
const h1tag =<h1>{display}</h1>;
export default h1tag;
Index.js
import React from 'react';
import ReactDOM from 'react-dom';
import h1tag from './test.jsx';
ReactDOM.render(
h1tag,
document.getElementById('root')
);
Check the same in the browser: http://www.localhost:3000/index.html
Difference between js and jsx files
ReactJS - .JS vs .JSX
There is none when it comes to file extensions. Your bundler/transpiler/whatever takes care of
resolving what type of file contents there is.
There are however some other considerations when deciding what to put into a .js or a .jsx file
type. Since JSX isn't standard JavaScript one could argue that anything that is not "plain"
JavaScript should go into its own extensions ie., .jsx for JSX and .ts for TypeScript for example.

More Related Content

PPTX
React js programming concept
PPTX
React workshop
PPTX
Express js
PPTX
Angular tutorial
PPTX
Introduction to react_js
PPTX
React hooks
PPTX
React workshop presentation
PPTX
A Brief Introduction to React.js
React js programming concept
React workshop
Express js
Angular tutorial
Introduction to react_js
React hooks
React workshop presentation
A Brief Introduction to React.js

What's hot (20)

PDF
Angular - Chapter 7 - HTTP Services
PDF
React JS - Introduction
PPTX
Introduction to Spring Boot
PPTX
ReactJs presentation
PDF
React JS & Functional Programming Principles
PDF
PUC SE Day 2019 - SpringBoot
PPTX
Introduction to React JS
PPTX
Introduction to spring boot
PPTX
Angular overview
PPTX
[Final] ReactJS presentation
PPTX
What Is Virtual DOM In React JS.pptx
PPTX
Intro to React
PPT
Angular 8
PDF
Nodejs presentation
PDF
Introduction to React Native
PPTX
Introduction to Node.js
PPTX
Introduction to Node js
PPT
Javascript
PPTX
Angularjs PPT
PPTX
How native is React Native? | React Native vs Native App Development
Angular - Chapter 7 - HTTP Services
React JS - Introduction
Introduction to Spring Boot
ReactJs presentation
React JS & Functional Programming Principles
PUC SE Day 2019 - SpringBoot
Introduction to React JS
Introduction to spring boot
Angular overview
[Final] ReactJS presentation
What Is Virtual DOM In React JS.pptx
Intro to React
Angular 8
Nodejs presentation
Introduction to React Native
Introduction to Node.js
Introduction to Node js
Javascript
Angularjs PPT
How native is React Native? | React Native vs Native App Development
Ad

Similar to React js t2 - jsx (20)

PDF
Understanding React JSX_ A Beginner's Guide
PPTX
React JSX.pptx
PDF
React cheetsheet. This is cheetsheet note of react
PDF
Learn react by Etietop Demas
PPTX
ReactJS.pptx
PDF
30 days-of-react-ebook-fullstackio
PDF
unit 3_Adv WTAdvanced Web Tecg Design_HTML_CSS_JAVASCRIPT_AJAX_PPT.pdf
PPTX
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
PDF
Reactjs workshop
PPTX
slides.pptx
PPTX
slides.pptx
PDF
Why I Love JSX!
PPTX
Unit 2 Fundamentals of React -------.pptx
PPTX
From JSX to Deployment: Mastering the React Workflow for Scalable Front-End D...
ODP
Introduction to ReactJS
PDF
learning react
PDF
FRONTEND BOOTCAMP 3.pdf
PPTX
React js
PPTX
Introduction to React native
Understanding React JSX_ A Beginner's Guide
React JSX.pptx
React cheetsheet. This is cheetsheet note of react
Learn react by Etietop Demas
ReactJS.pptx
30 days-of-react-ebook-fullstackio
unit 3_Adv WTAdvanced Web Tecg Design_HTML_CSS_JAVASCRIPT_AJAX_PPT.pdf
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
Reactjs workshop
slides.pptx
slides.pptx
Why I Love JSX!
Unit 2 Fundamentals of React -------.pptx
From JSX to Deployment: Mastering the React Workflow for Scalable Front-End D...
Introduction to ReactJS
learning react
FRONTEND BOOTCAMP 3.pdf
React js
Introduction to React native
Ad

More from Jainul Musani (20)

PDF
Core Java Interface Concepts for BCA Studetns
PDF
Java Abstract and Final Class for BCA students
PDF
Java Collection Framework for BCA Students
PDF
Simple Calculator using JavaFx a part of Advance Java
PDF
JavaFx Introduction, Basic JavaFx Architecture
PDF
ASP.NET 2010, WebServices Full Example for BCA Students
PDF
Palindrome Programme in PHP for BCA students
PDF
Leap Year Program in PHP for BCA students
PDF
"PHP and MySQL CRUD Operations for Student Management System"
PDF
Python: The Versatile Programming Language - Introduction
PPTX
Python a Versatile Programming Language - Introduction
PDF
React js t8 - inlinecss
PDF
React js t7 - forms-events
PDF
React js t6 -lifecycle
PDF
React js t5 - state
PDF
React js t4 - components
PDF
React js t3 - es6
PDF
React js t1 - introduction
PPTX
ExpressJs Session01
PPTX
NodeJs Session03
Core Java Interface Concepts for BCA Studetns
Java Abstract and Final Class for BCA students
Java Collection Framework for BCA Students
Simple Calculator using JavaFx a part of Advance Java
JavaFx Introduction, Basic JavaFx Architecture
ASP.NET 2010, WebServices Full Example for BCA Students
Palindrome Programme in PHP for BCA students
Leap Year Program in PHP for BCA students
"PHP and MySQL CRUD Operations for Student Management System"
Python: The Versatile Programming Language - Introduction
Python a Versatile Programming Language - Introduction
React js t8 - inlinecss
React js t7 - forms-events
React js t6 -lifecycle
React js t5 - state
React js t4 - components
React js t3 - es6
React js t1 - introduction
ExpressJs Session01
NodeJs Session03

Recently uploaded (20)

PDF
Insight into Romanian Wild-Grown Heracleum sphondylium: Development of a New ...
PDF
WHAT NURSES SAY_ COMMUNICATION BEHAVIORS ASSOCIATED WITH THE COMP.pdf
PDF
17649-Learning By Doing_text-tailieu.pdf
PDF
Physical pharmaceutics two in b pharmacy
PDF
Teacher's Day Quiz 2025
PDF
Developing speaking skill_learning_mater.pdf
PDF
Financial Reporting and Analysis Using Financial Accounting Information by Ch...
PDF
Unleashing the Potential of the Cultural and creative industries
PDF
V02-Session-4-Leadership-Through-Assessment-MLB.pdf
PPTX
ENGlishGrade8_Quarter2_WEEK1_LESSON1.pptx
PPTX
Juvenile delinquency-Crim Research day 3x
PDF
BA-1ST(Education)-Education and Society.pdf
PDF
English 2nd semesteNotesh biology biopsy results from the other day and I jus...
PDF
2003-theological-education-v39-n1-tai lieu
PPTX
FILIPINO 8 Q2 WEEK 1(DAY 1).power point presentation
PPTX
Ppt obs emergecy.pptxydirnbduejguxjjdjidjdbuc
PDF
gsas-cvs-and-cover-letters jhvgfcffttfghgvhg.pdf
PPTX
UCSP Section A - Human Cultural Variations,Social Differences,social ChangeCo...
PPTX
Power of Gratitude: Honouring our teachers
PDF
BA-1ST(Education)-Education and Society.pdf
Insight into Romanian Wild-Grown Heracleum sphondylium: Development of a New ...
WHAT NURSES SAY_ COMMUNICATION BEHAVIORS ASSOCIATED WITH THE COMP.pdf
17649-Learning By Doing_text-tailieu.pdf
Physical pharmaceutics two in b pharmacy
Teacher's Day Quiz 2025
Developing speaking skill_learning_mater.pdf
Financial Reporting and Analysis Using Financial Accounting Information by Ch...
Unleashing the Potential of the Cultural and creative industries
V02-Session-4-Leadership-Through-Assessment-MLB.pdf
ENGlishGrade8_Quarter2_WEEK1_LESSON1.pptx
Juvenile delinquency-Crim Research day 3x
BA-1ST(Education)-Education and Society.pdf
English 2nd semesteNotesh biology biopsy results from the other day and I jus...
2003-theological-education-v39-n1-tai lieu
FILIPINO 8 Q2 WEEK 1(DAY 1).power point presentation
Ppt obs emergecy.pptxydirnbduejguxjjdjidjdbuc
gsas-cvs-and-cover-letters jhvgfcffttfghgvhg.pdf
UCSP Section A - Human Cultural Variations,Social Differences,social ChangeCo...
Power of Gratitude: Honouring our teachers
BA-1ST(Education)-Education and Society.pdf

React js t2 - jsx

  • 1. ReactJs : Tutorial-02-JSX What is JSX?  JSX is an extension to javascript.  It is a template script where you will have the power of using HTML and Javascript together. Here is a simple example of a JSX code. const h1tag = "<h1>Hello, from RTDL Tutorials!</h1>"; Why we need JSX in React? For a UI, we need Html, and each element in the DOM will have events to be handled, state changes, etc. In case of React, it allows us to make use of Html and javascript in the same file and take care of the state changes in the DOM in an efficient manner. Expressions in JSX index.js import React from 'react'; import ReactDOM from 'react-dom'; ReactDOM.render( <h1>Hello, from RTDL Tutorials!</h1>, document.getElementById('root') ); index.js import React from 'react'; import ReactDOM from 'react-dom'; const display = "Hello, from RTDL Tutori als!"; const h1tag = "<h1>{display}</h1>"; ReactDOM.render( h1tag, document.getElementById('root') ); The Output will show the line as
  • 2. ReactJs : Tutorial-02-JSX What is the solution of this? Create a text.jsx file and put the code in the file. Import the test.jsx file in to index.js file and use it. test.jsx import React from 'react'; import ReactDOM from 'react-dom'; const display = "Hello, to RTDL Tutorial s"; const h1tag =<h1>{display}</h1>; export default h1tag; Index.js import React from 'react'; import ReactDOM from 'react-dom'; import h1tag from './test.jsx'; ReactDOM.render( h1tag, document.getElementById('root') ); Check the same in the browser: http://www.localhost:3000/index.html Difference between js and jsx files ReactJS - .JS vs .JSX There is none when it comes to file extensions. Your bundler/transpiler/whatever takes care of resolving what type of file contents there is. There are however some other considerations when deciding what to put into a .js or a .jsx file type. Since JSX isn't standard JavaScript one could argue that anything that is not "plain" JavaScript should go into its own extensions ie., .jsx for JSX and .ts for TypeScript for example.