SlideShare a Scribd company logo
7
Most read
12
Most read
17
Most read
Intro to ReactJS
Varun Raj
Sr. Application Architect @ Skcript
varun@skcript.com @zathvarun
About Me
Library for building User Interfaces
V part of MVC ( Model View Controller )
Not a front end framework
What is React ?
And React is not a templating library
Why To Use React ?
Simple
Declarative
Build Reusable Components
React Uses JSX (JavaScript & XML)
Standard HTML - Accept all attributes
Little modifications like className instead of class
var CommentBox = React.createClass({
render: function() {
return (
<div className="commentBox">
Hello, world! I am a CommentBox.
</div>
);
}
});
Virtual DOM
React uses a concept called Virtual DOM
It’s Faster for re-rendering the entire component on every state change.
Virtual DOM uses diff algorithm.
Can rendered in server and synced with local client.
Three Important Terminologies
Components
States
Props
Components
Everything is a component in react
Created using React.createClass
Key functions for every components
getInitialState: function() {},
componentWillMount : function() {},
componentDidMount : function() {},
componentWillUnmount : function() {},
componentDidUnmount : function() {},
render : function() {}
Introduction to React JS for beginners
Props
Loaded as attributes for components
Used for unidirectional data flow
immutable or read only
var CommentBox = React.createClass({
render: function() {
return (
<div className="commentBox">{this.props.message}</div>
);
}
});
ReactDOM.render(<CommentBox message=”Say Hello”/>,document.getElementById('content'));
Defines states of a component.
Changes to the state causes re rendering of the entire component.
getInitialState() is used to set initial states of the component
setstate({state: value}) is used to update the state
States
Render Function
The Actual View Code is written here
States and Props both are read-only here
Returns JSX Elements
render: function() {
return (
<div className="commentBox">{this.props.message}</div>
);
}
Forms
Form elements are pointed or named with ref attribute
From values are extracted like this.refs.searchInput.value where
searchInput is the ref of the input element
Default value is set with help of defaultValue attribute.
Events
Cross Browser Events
CamelCase Event Handlers
onDragStart
onDrop
onMouseDown
onMouseEnter
onMouseLeave
onMouseMove
onMouseOut
onMouseOver
onMouseUp
onClick
onContextMenu
onDoubleClick
onDrag
onDragEnd
onDragEnter
onDragExit
onDragLeave
onDragOver
Component LifeCycle
TODO LIST EXAMPLE
var TodoList = React.createClass({
render: function() {
var createItem = function(item) {
return <li key={item.id}>{item.text}</li>;
};
return <ul>{this.props.items.map(createItem)}</ul>;
}
});
var TodoApp = React.createClass({
getInitialState: function() { return {items: [], text: ''};},
onChange: function(e) {
this.setState({text: e.target.value});
},
handleSubmit: function(e) {
e.preventDefault();
var nextItems = this.state.items.concat([{text: this.state.text, id: Date.now()}]);
var nextText = '';
this.setState({items: nextItems, text: nextText});
},
render: function() {
return (
<div>
<h3>TODO</h3>
<TodoList items={this.state.items} />
<form onSubmit={this.handleSubmit}>
<input onChange={this.onChange} value={this.state.text} />
<button>{'Add #' + (this.state.items.length + 1)}</button>
</form>
</div>
);
}
});
ReactDOM.render(<TodoApp />, mountNode);
Useful tools when developing in React
HTML to JSX Compiler
React Developer Tools for Chrome
React Developer Tools for Firefox
Sites built with React
Facebook
Whatsapp Web
netflix
BlankCursor
Instagram
Producthunt
messenger.com
Introduction to React JS for beginners
Thank You !
varun@skcript.com @zathvarun

More Related Content

What's hot (20)

PPTX
Introduction to react_js
MicroPyramid .
 
PPTX
Intro to React
Justin Reock
 
PPTX
React js programming concept
Tariqul islam
 
ODP
Introduction to ReactJS
Knoldus Inc.
 
PDF
React JS - Introduction
Sergey Romaneko
 
PPTX
reactJS
Syam Santhosh
 
PDF
An introduction to React.js
Emanuele DelBono
 
PPTX
React workshop
Imran Sayed
 
PPTX
React js
Oswald Campesato
 
PPTX
Its time to React.js
Ritesh Mehrotra
 
PPTX
ReactJs
Sahana Banerjee
 
PPTX
Reactjs
Neha Sharma
 
PDF
WEB DEVELOPMENT USING REACT JS
MuthuKumaran Singaravelu
 
PDF
Workshop 21: React Router
Visual Engineering
 
PPTX
React js for beginners
Alessandro Valenti
 
PPTX
Introduction to React
Rob Quick
 
PPTX
React-JS.pptx
AnmolPandita7
 
PPTX
React + Redux Introduction
Nikolaus Graf
 
PDF
ReactJS
Hiten Pratap Singh
 
PPTX
Introduction to react js
Aeshan Wijetunge
 
Introduction to react_js
MicroPyramid .
 
Intro to React
Justin Reock
 
React js programming concept
Tariqul islam
 
Introduction to ReactJS
Knoldus Inc.
 
React JS - Introduction
Sergey Romaneko
 
reactJS
Syam Santhosh
 
An introduction to React.js
Emanuele DelBono
 
React workshop
Imran Sayed
 
Its time to React.js
Ritesh Mehrotra
 
Reactjs
Neha Sharma
 
WEB DEVELOPMENT USING REACT JS
MuthuKumaran Singaravelu
 
Workshop 21: React Router
Visual Engineering
 
React js for beginners
Alessandro Valenti
 
Introduction to React
Rob Quick
 
React-JS.pptx
AnmolPandita7
 
React + Redux Introduction
Nikolaus Graf
 
Introduction to react js
Aeshan Wijetunge
 

Similar to Introduction to React JS for beginners (20)

PPTX
Intro react js
Vijayakanth MP
 
PPTX
Dyanaimcs of business and economics unit 2
jpm071712
 
PPTX
Introduction to React
Sebastian Pederiva
 
PPTX
ReactJS (1)
George Tony
 
PPTX
Reactjs
Shubham Gupta
 
PPTX
React/Redux
Durgesh Vaishnav
 
PDF
Stay with React.js in 2020
Jerry Liao
 
PDF
Welcome to React & Flux !
Ritesh Kumar
 
PPTX
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
Ayes Chinmay
 
PDF
Introduction to React
Yos Riady
 
PDF
Reactjspdf
Shubham Gupta
 
PPTX
React & Redux for noobs
[T]echdencias
 
PDF
Workshop 19: ReactJS Introduction
Visual Engineering
 
PDF
React for Dummies
Mitch Chen
 
PPTX
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
Karmanjay Verma
 
PPTX
Introduction to React and MobX
Anjali Chawla
 
PDF
React && React Native workshop
Stacy Goh
 
PDF
Introduction Web Development using ReactJS
ssuser8a1f37
 
PPTX
ReactJS presentation.pptx
DivyanshGupta922023
 
PDF
unit 3_Adv WTAdvanced Web Tecg Design_HTML_CSS_JAVASCRIPT_AJAX_PPT.pdf
GauravDwivedi695361
 
Intro react js
Vijayakanth MP
 
Dyanaimcs of business and economics unit 2
jpm071712
 
Introduction to React
Sebastian Pederiva
 
ReactJS (1)
George Tony
 
Reactjs
Shubham Gupta
 
React/Redux
Durgesh Vaishnav
 
Stay with React.js in 2020
Jerry Liao
 
Welcome to React & Flux !
Ritesh Kumar
 
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
Ayes Chinmay
 
Introduction to React
Yos Riady
 
Reactjspdf
Shubham Gupta
 
React & Redux for noobs
[T]echdencias
 
Workshop 19: ReactJS Introduction
Visual Engineering
 
React for Dummies
Mitch Chen
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
Karmanjay Verma
 
Introduction to React and MobX
Anjali Chawla
 
React && React Native workshop
Stacy Goh
 
Introduction Web Development using ReactJS
ssuser8a1f37
 
ReactJS presentation.pptx
DivyanshGupta922023
 
unit 3_Adv WTAdvanced Web Tecg Design_HTML_CSS_JAVASCRIPT_AJAX_PPT.pdf
GauravDwivedi695361
 
Ad

Recently uploaded (20)

PPTX
MODULE 03 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
PDF
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
PDF
Module - 5 Machine Learning-22ISE62.pdf
Dr. Shivashankar
 
PPTX
Distribution reservoir and service storage pptx
dhanashree78
 
PPTX
Unit_I Functional Units, Instruction Sets.pptx
logaprakash9
 
PDF
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
PDF
Electrical Machines and Their Protection.pdf
Nabajyoti Banik
 
PDF
William Stallings - Foundations of Modern Networking_ SDN, NFV, QoE, IoT, and...
lavanya896395
 
PPTX
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
PPTX
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
PDF
Bayesian Learning - Naive Bayes Algorithm
Sharmila Chidaravalli
 
PPTX
How Industrial Project Management Differs From Construction.pptx
jamespit799
 
PDF
mbse_An_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
PDF
Bachelor of information technology syll
SudarsanAssistantPro
 
PPTX
Basics of Electrical Engineering and electronics .pptx
PrabhuNarayan6
 
PPTX
Fundamentals of Quantitative Design and Analysis.pptx
aliali240367
 
PDF
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
PPTX
Knowledge Representation : Semantic Networks
Amity University, Patna
 
PPT
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
PDF
Submit Your Papers-International Journal on Cybernetics & Informatics ( IJCI)
IJCI JOURNAL
 
MODULE 03 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
Module - 5 Machine Learning-22ISE62.pdf
Dr. Shivashankar
 
Distribution reservoir and service storage pptx
dhanashree78
 
Unit_I Functional Units, Instruction Sets.pptx
logaprakash9
 
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
Electrical Machines and Their Protection.pdf
Nabajyoti Banik
 
William Stallings - Foundations of Modern Networking_ SDN, NFV, QoE, IoT, and...
lavanya896395
 
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
Bayesian Learning - Naive Bayes Algorithm
Sharmila Chidaravalli
 
How Industrial Project Management Differs From Construction.pptx
jamespit799
 
mbse_An_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
Bachelor of information technology syll
SudarsanAssistantPro
 
Basics of Electrical Engineering and electronics .pptx
PrabhuNarayan6
 
Fundamentals of Quantitative Design and Analysis.pptx
aliali240367
 
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
Knowledge Representation : Semantic Networks
Amity University, Patna
 
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
Submit Your Papers-International Journal on Cybernetics & Informatics ( IJCI)
IJCI JOURNAL
 
Ad

Introduction to React JS for beginners

  • 2. Varun Raj Sr. Application Architect @ Skcript [email protected] @zathvarun About Me
  • 3. Library for building User Interfaces V part of MVC ( Model View Controller ) Not a front end framework What is React ?
  • 4. And React is not a templating library
  • 5. Why To Use React ? Simple Declarative Build Reusable Components
  • 6. React Uses JSX (JavaScript & XML) Standard HTML - Accept all attributes Little modifications like className instead of class var CommentBox = React.createClass({ render: function() { return ( <div className="commentBox"> Hello, world! I am a CommentBox. </div> ); } });
  • 7. Virtual DOM React uses a concept called Virtual DOM It’s Faster for re-rendering the entire component on every state change. Virtual DOM uses diff algorithm. Can rendered in server and synced with local client.
  • 9. Components Everything is a component in react Created using React.createClass Key functions for every components getInitialState: function() {}, componentWillMount : function() {}, componentDidMount : function() {}, componentWillUnmount : function() {}, componentDidUnmount : function() {}, render : function() {}
  • 11. Props Loaded as attributes for components Used for unidirectional data flow immutable or read only var CommentBox = React.createClass({ render: function() { return ( <div className="commentBox">{this.props.message}</div> ); } }); ReactDOM.render(<CommentBox message=”Say Hello”/>,document.getElementById('content'));
  • 12. Defines states of a component. Changes to the state causes re rendering of the entire component. getInitialState() is used to set initial states of the component setstate({state: value}) is used to update the state States
  • 13. Render Function The Actual View Code is written here States and Props both are read-only here Returns JSX Elements render: function() { return ( <div className="commentBox">{this.props.message}</div> ); }
  • 14. Forms Form elements are pointed or named with ref attribute From values are extracted like this.refs.searchInput.value where searchInput is the ref of the input element Default value is set with help of defaultValue attribute.
  • 15. Events Cross Browser Events CamelCase Event Handlers onDragStart onDrop onMouseDown onMouseEnter onMouseLeave onMouseMove onMouseOut onMouseOver onMouseUp onClick onContextMenu onDoubleClick onDrag onDragEnd onDragEnter onDragExit onDragLeave onDragOver
  • 17. TODO LIST EXAMPLE var TodoList = React.createClass({ render: function() { var createItem = function(item) { return <li key={item.id}>{item.text}</li>; }; return <ul>{this.props.items.map(createItem)}</ul>; } }); var TodoApp = React.createClass({ getInitialState: function() { return {items: [], text: ''};}, onChange: function(e) { this.setState({text: e.target.value}); }, handleSubmit: function(e) { e.preventDefault(); var nextItems = this.state.items.concat([{text: this.state.text, id: Date.now()}]); var nextText = ''; this.setState({items: nextItems, text: nextText}); }, render: function() { return ( <div> <h3>TODO</h3> <TodoList items={this.state.items} /> <form onSubmit={this.handleSubmit}> <input onChange={this.onChange} value={this.state.text} /> <button>{'Add #' + (this.state.items.length + 1)}</button> </form> </div> ); } }); ReactDOM.render(<TodoApp />, mountNode);
  • 18. Useful tools when developing in React HTML to JSX Compiler React Developer Tools for Chrome React Developer Tools for Firefox
  • 19. Sites built with React Facebook Whatsapp Web netflix BlankCursor Instagram Producthunt messenger.com

Editor's Notes

  • #4: Can also be used with angularjs React has routes
  • #7: Written inside render fucntion Add tags must be closed properly purely xml has inline event lisenters
  • #8: Not similar to Shadow DOM can be seen in normal dom but with special attributes like react-id
  • #9: Also there are few other things like Mixins refs
  • #10: Can be nested Mounted unmounted dynamically They as like partials but in different manner
  • #11: Completly react Whatsapp Web
  • #12: Read Only Attributes Sent from the render call can also set default props from component with special function call getDefaultProps Usually props to be chaged are stored to statees and then the state is modified
  • #13: Initialied based on the some condition or from props states controls the modification changes reflects in rerendering
  • #18: Example of todo list application from the official docs