SlideShare a Scribd company logo
ReactJs : Tutorial-05-State in ReactJs
What is State in React JS?
A state is a JavaScript object similar to props that have data to be used with the reactjs render.
The state data is a private object and is used within components inside a class.
Components as functions
test.jsx
import React from 'react';
import ReactDOM from 'react-dom';
class Hello extends React.Component {
constructor(props) {
super(props);
this.state = {
msg: "Hello, RTDL - Tutorials!"
}
}
render() {
return <h1>{this.state.msg}</h1>;
}
}
export default Hello;
index.jsx
import React from 'react';
import ReactDOM from 'react-dom';
import Hello from './test.jsx';
ReactDOM.render(
<Hello />,
document.getElementById('root')
);

More Related Content

What's hot (20)

PPTX
React-JS Component Life-cycle Methods
ANKUSH CHAVAN
 
PDF
React and redux
Mystic Coders, LLC
 
PDF
Introduction to React Hooks
Felicia O'Garro
 
PPTX
React - Start learning today
Nitin Tyagi
 
PPTX
React redux-redux-saga-rahil-memon
RahilMemon5
 
PDF
Workshop 20: ReactJS Part II Flux Pattern & Redux
Visual Engineering
 
PDF
Understanding react hooks
Samundra khatri
 
PPTX
React js
Alireza Akbari
 
PDF
An Introduction to Redux
NexThoughts Technologies
 
ODP
Introduction to ReactJS
Knoldus Inc.
 
PPTX
Introduction to React JS
Arnold Asllani
 
PPTX
React js programming concept
Tariqul islam
 
PDF
React + Redux. Best practices
Clickky
 
PPTX
React JS part 1
Diluka Wittahachchige
 
PDF
Workshop 19: ReactJS Introduction
Visual Engineering
 
PPTX
Intro to React
Eric Westfall
 
PDF
React native app with type script tutorial
Katy Slemon
 
PDF
React Redux Tutorial | Redux Tutorial for Beginners | React Redux Training | ...
Edureka!
 
PDF
Redux and context api with react native app introduction, use cases, implemen...
Katy Slemon
 
PPTX
React and Flux life cycle with JSX, React Router and Jest Unit Testing
Eswara Kumar Palakollu
 
React-JS Component Life-cycle Methods
ANKUSH CHAVAN
 
React and redux
Mystic Coders, LLC
 
Introduction to React Hooks
Felicia O'Garro
 
React - Start learning today
Nitin Tyagi
 
React redux-redux-saga-rahil-memon
RahilMemon5
 
Workshop 20: ReactJS Part II Flux Pattern & Redux
Visual Engineering
 
Understanding react hooks
Samundra khatri
 
React js
Alireza Akbari
 
An Introduction to Redux
NexThoughts Technologies
 
Introduction to ReactJS
Knoldus Inc.
 
Introduction to React JS
Arnold Asllani
 
React js programming concept
Tariqul islam
 
React + Redux. Best practices
Clickky
 
React JS part 1
Diluka Wittahachchige
 
Workshop 19: ReactJS Introduction
Visual Engineering
 
Intro to React
Eric Westfall
 
React native app with type script tutorial
Katy Slemon
 
React Redux Tutorial | Redux Tutorial for Beginners | React Redux Training | ...
Edureka!
 
Redux and context api with react native app introduction, use cases, implemen...
Katy Slemon
 
React and Flux life cycle with JSX, React Router and Jest Unit Testing
Eswara Kumar Palakollu
 

More from Jainul Musani (20)

PDF
Core Java Interface Concepts for BCA Studetns
Jainul Musani
 
PDF
Java Abstract and Final Class for BCA students
Jainul Musani
 
PDF
Java Collection Framework for BCA Students
Jainul Musani
 
PDF
Simple Calculator using JavaFx a part of Advance Java
Jainul Musani
 
PDF
JavaFx Introduction, Basic JavaFx Architecture
Jainul Musani
 
PDF
ASP.NET 2010, WebServices Full Example for BCA Students
Jainul Musani
 
PDF
Palindrome Programme in PHP for BCA students
Jainul Musani
 
PDF
Leap Year Program in PHP for BCA students
Jainul Musani
 
PDF
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
 
PDF
Python: The Versatile Programming Language - Introduction
Jainul Musani
 
PPTX
Python a Versatile Programming Language - Introduction
Jainul Musani
 
PDF
React js t2 - jsx
Jainul Musani
 
PPTX
ExpressJs Session01
Jainul Musani
 
PPTX
NodeJs Session03
Jainul Musani
 
PPTX
NodeJs Session02
Jainul Musani
 
PPTX
Nodejs Session01
Jainul Musani
 
PDF
Java exercise1
Jainul Musani
 
PPSX
Fundamentals of JDBC
Jainul Musani
 
PPT
Core Java Special
Jainul Musani
 
PDF
Core Java Special
Jainul Musani
 
Core Java Interface Concepts for BCA Studetns
Jainul Musani
 
Java Abstract and Final Class for BCA students
Jainul Musani
 
Java Collection Framework for BCA Students
Jainul Musani
 
Simple Calculator using JavaFx a part of Advance Java
Jainul Musani
 
JavaFx Introduction, Basic JavaFx Architecture
Jainul Musani
 
ASP.NET 2010, WebServices Full Example for BCA Students
Jainul Musani
 
Palindrome Programme in PHP for BCA students
Jainul Musani
 
Leap Year Program in PHP for BCA students
Jainul Musani
 
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
 
Python: The Versatile Programming Language - Introduction
Jainul Musani
 
Python a Versatile Programming Language - Introduction
Jainul Musani
 
React js t2 - jsx
Jainul Musani
 
ExpressJs Session01
Jainul Musani
 
NodeJs Session03
Jainul Musani
 
NodeJs Session02
Jainul Musani
 
Nodejs Session01
Jainul Musani
 
Java exercise1
Jainul Musani
 
Fundamentals of JDBC
Jainul Musani
 
Core Java Special
Jainul Musani
 
Core Java Special
Jainul Musani
 
Ad

Recently uploaded (20)

PPTX
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
PPTX
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
PPTX
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
PPTX
Difference between write and update in odoo 18
Celine George
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
PDF
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
PDF
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
PPTX
infertility, types,causes, impact, and management
Ritu480198
 
PPTX
Controller Request and Response in Odoo18
Celine George
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PDF
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
PDF
Council of Chalcedon Re-Examined
Smiling Lungs
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
PPTX
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
Difference between write and update in odoo 18
Celine George
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
infertility, types,causes, impact, and management
Ritu480198
 
Controller Request and Response in Odoo18
Celine George
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
Council of Chalcedon Re-Examined
Smiling Lungs
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
Ad

React js t5 - state

  • 1. ReactJs : Tutorial-05-State in ReactJs What is State in React JS? A state is a JavaScript object similar to props that have data to be used with the reactjs render. The state data is a private object and is used within components inside a class. Components as functions test.jsx import React from 'react'; import ReactDOM from 'react-dom'; class Hello extends React.Component { constructor(props) { super(props); this.state = { msg: "Hello, RTDL - Tutorials!" } } render() { return <h1>{this.state.msg}</h1>; } } export default Hello; index.jsx import React from 'react'; import ReactDOM from 'react-dom'; import Hello from './test.jsx'; ReactDOM.render( <Hello />, document.getElementById('root') );