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

PPTX
Introduction to React JS
Arnold Asllani
 
PPTX
[Final] ReactJS presentation
洪 鹏发
 
PDF
ReactJS presentation
Thanh Tuong
 
PPTX
Introduction to React JS for beginners | Namespace IT
namespaceit
 
PPTX
React JS - A quick introduction tutorial
Mohammed Fazuluddin
 
PPTX
React workshop
Imran Sayed
 
PPTX
Intro to React
Eric Westfall
 
PPTX
Its time to React.js
Ritesh Mehrotra
 
Introduction to React JS
Arnold Asllani
 
[Final] ReactJS presentation
洪 鹏发
 
ReactJS presentation
Thanh Tuong
 
Introduction to React JS for beginners | Namespace IT
namespaceit
 
React JS - A quick introduction tutorial
Mohammed Fazuluddin
 
React workshop
Imran Sayed
 
Intro to React
Eric Westfall
 
Its time to React.js
Ritesh Mehrotra
 

What's hot (20)

PDF
React JS - Introduction
Sergey Romaneko
 
PDF
An introduction to React.js
Emanuele DelBono
 
PDF
ReactJS
Hiten Pratap Singh
 
PPTX
Reactjs
Neha Sharma
 
PPTX
ReactJs
Sahana Banerjee
 
PPTX
Introduction to React
Rob Quick
 
ODP
Introduction to ReactJS
Knoldus Inc.
 
PPTX
Intro to React
Justin Reock
 
PPTX
React js for beginners
Alessandro Valenti
 
PPTX
Introduction to react_js
MicroPyramid .
 
PDF
React js
Rajesh Kolla
 
PPTX
React-JS.pptx
AnmolPandita7
 
PPTX
ReactJS presentation.pptx
DivyanshGupta922023
 
PPTX
reactJS
Syam Santhosh
 
PDF
An Introduction to ReactJS
All Things Open
 
PPTX
React JS: A Secret Preview
valuebound
 
PPT
React js
Jai Santhosh
 
PPTX
React js
Oswald Campesato
 
PDF
Introduction to React JS
Bethmi Gunasekara
 
React JS - Introduction
Sergey Romaneko
 
An introduction to React.js
Emanuele DelBono
 
Reactjs
Neha Sharma
 
Introduction to React
Rob Quick
 
Introduction to ReactJS
Knoldus Inc.
 
Intro to React
Justin Reock
 
React js for beginners
Alessandro Valenti
 
Introduction to react_js
MicroPyramid .
 
React js
Rajesh Kolla
 
React-JS.pptx
AnmolPandita7
 
ReactJS presentation.pptx
DivyanshGupta922023
 
reactJS
Syam Santhosh
 
An Introduction to ReactJS
All Things Open
 
React JS: A Secret Preview
valuebound
 
React js
Jai Santhosh
 
Introduction to React JS
Bethmi Gunasekara
 
Ad

Similar to Introduction to React JS for beginners (20)

PPTX
ReactJS
Ram Murat Sharma
 
PPTX
React & Redux for noobs
[T]echdencias
 
PDF
Reactивная тяга
Vitebsk Miniq
 
PPTX
Intro react js
Vijayakanth MP
 
PPTX
React/Redux
Durgesh Vaishnav
 
PPTX
ReactJS (1)
George Tony
 
PPTX
React - Start learning today
Nitin Tyagi
 
PDF
Manage the Flux of your Web Application: Let's Redux
Commit University
 
PPTX
React outbox
Angela Lehru
 
PPTX
Combining Angular and React Together
Sebastian Pederiva
 
PDF
React lecture
Christoffer Noring
 
PPTX
Dyanaimcs of business and economics unit 2
jpm071712
 
PDF
React for Re-use: Creating UI Components with Confluence Connect
Atlassian
 
PPTX
Getting Started With ReactJS
Sandeep Kumar Patel
 
PPTX
react-slides.pptx
DayNightGaMiNg
 
PPTX
react-slidlkjfl;kj;dlkjopidfjhopijgpoerjpofjiwoepifjopweifjepoies.pptx
PrathamSharma77833
 
PPTX
TRAINING pptt efwoiefo weoifjoiewjfoifjow.pptx
PrathamSharma77833
 
PDF
React native
Vishal Dubey
 
PPTX
Introduction to React and MobX
Anjali Chawla
 
PDF
Fundamental concepts of react js
StephieJohn
 
React & Redux for noobs
[T]echdencias
 
Reactивная тяга
Vitebsk Miniq
 
Intro react js
Vijayakanth MP
 
React/Redux
Durgesh Vaishnav
 
ReactJS (1)
George Tony
 
React - Start learning today
Nitin Tyagi
 
Manage the Flux of your Web Application: Let's Redux
Commit University
 
React outbox
Angela Lehru
 
Combining Angular and React Together
Sebastian Pederiva
 
React lecture
Christoffer Noring
 
Dyanaimcs of business and economics unit 2
jpm071712
 
React for Re-use: Creating UI Components with Confluence Connect
Atlassian
 
Getting Started With ReactJS
Sandeep Kumar Patel
 
react-slides.pptx
DayNightGaMiNg
 
react-slidlkjfl;kj;dlkjopidfjhopijgpoerjpofjiwoepifjopweifjepoies.pptx
PrathamSharma77833
 
TRAINING pptt efwoiefo weoifjoiewjfoifjow.pptx
PrathamSharma77833
 
React native
Vishal Dubey
 
Introduction to React and MobX
Anjali Chawla
 
Fundamental concepts of react js
StephieJohn
 
Ad

Recently uploaded (20)

DOCX
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
PDF
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
PDF
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
PPTX
22PCOAM21 Session 1 Data Management.pptx
Guru Nanak Technical Institutions
 
PPTX
Information Retrieval and Extraction - Module 7
premSankar19
 
PDF
The Effect of Artifact Removal from EEG Signals on the Detection of Epileptic...
Partho Prosad
 
PDF
top-5-use-cases-for-splunk-security-analytics.pdf
yaghutialireza
 
PPTX
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
PPTX
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
PDF
Queuing formulas to evaluate throughputs and servers
gptshubham
 
PDF
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
PPTX
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PDF
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
PPTX
unit 3a.pptx material management. Chapter of operational management
atisht0104
 
PDF
dse_final_merit_2025_26 gtgfffffcjjjuuyy
rushabhjain127
 
PDF
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
PPT
SCOPE_~1- technology of green house and poyhouse
bala464780
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PDF
Top 10 read articles In Managing Information Technology.pdf
IJMIT JOURNAL
 
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
22PCOAM21 Session 1 Data Management.pptx
Guru Nanak Technical Institutions
 
Information Retrieval and Extraction - Module 7
premSankar19
 
The Effect of Artifact Removal from EEG Signals on the Detection of Epileptic...
Partho Prosad
 
top-5-use-cases-for-splunk-security-analytics.pdf
yaghutialireza
 
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
Queuing formulas to evaluate throughputs and servers
gptshubham
 
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
unit 3a.pptx material management. Chapter of operational management
atisht0104
 
dse_final_merit_2025_26 gtgfffffcjjjuuyy
rushabhjain127
 
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
SCOPE_~1- technology of green house and poyhouse
bala464780
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
Top 10 read articles In Managing Information Technology.pdf
IJMIT JOURNAL
 

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