Introduction to ReactJS

AdroitLogic
AdroitLogicAdroitLogic
ReactJSPresented by Sajith Dilshan
First Project
$ npm install -g create-react-app
$ create-react-app hello-world
$ cd hello-world
$ npm start
Let’s see how it
really works
Components
import React, { Component } from 'react';
class App extends Component {
render() {
return (
<div className="App">
<h1> Hello World </h1>
</div>
);
}
}
export default App;
React JSXsyntactic-sugar for JS
const element =
(
<h1 className="greeting">
Hello, world!
</h1>
);
JSX Code
const element =
React.createElement(
'h1',
{className: 'greeting'},
'Hello, world!'
);
Compiled JS Code
• Template Language with full power of JS
• Prevents injection attacks
https://facebook.github.io/react/docs/introducing-jsx.html
more…
https://facebook.github.io/react/docs/jsx-in-depth.html
State vs.Props
•STATE - Specific to a particular component (to track the
changes of the component
•PROPS - Passed from the parent Component.Inputs to
the child component
Features STATE PROPS
Can get initial value from parent
component?
Yes Yes
Can be directly changed by parent
component?
No Yes
Can set default values inside
component?
Yes Yes
Can change inside component? Yes No
Can set initial value for child
component?
Yes Yes
Can change in child component? Yes No
Component Events - Mounting
• constructor()
• componentWillMount()
• render()
• componentDidMount()
Component Events - Updating
• componentWillReceiveProps(nextProps)
• shouldComponentUpdate(nextProps,nextState)
• componentWillUpdate(nextProps,nextState)
• render()
• componentDidUpdate(prevProps,prevState)
Component Events - Unmounting
• componentWillUnmount()
Instance Properties,API
• props
• state
• setState()
• forceUpdate()
Virtual DOM
User’s View
(Real DOM)
Background JS Process
(Virtual DOM)
Initial State
Virtual DOM
User’s View
(Real DOM)
Background JS Process
(Virtual DOM)
First Render
<html>
<div>
<h1>Sajith</h1>
</div>
</html>
Virtual DOM
User’s View
(Real DOM)
Background JS Process
(Virtual DOM)
Real DOM populated and Virtual DOM cleared
<html>
<div>
<h1>Sajith</h1>
</div>
</html>
<html>
<div>
<h1>Sajith</h1>
</div>
</html>
Virtual DOM
User’s View
(Real DOM)
Background JS Process
(Virtual DOM)
Click on Change Me
<html>
<div>
<h1>Sajith</h1>
</div>
</html>
<html>
<div>
<h1>Dilshan</h1>
</div>
</html>
Virtual DOM
User’s View
(Real DOM)
Background JS Process
(Virtual DOM)
Only modified section is updated in Real DOM and
Virtual DOM is cleared
<html>
<div>
<h1>Dilshan</h1>
</div>
</html>
<html>
<div>
<h1>Dilshan</h1>
</div>
</html>
<html>
<div>
<h1>Sajith</h1>
</div>
</html>
Reconciliation
• Use “diffing” algorithm
• the state of the art algorithms have a
complexity in the order of O(n3) where n is
the number of elements in the tree.
• React implements a heuristic O(n)
algorithm
https://facebook.github.io/react/docs/reconciliation.html
Flux
Action
Dispatcher Store View
Flux
Action
Dispatcher Store View
Flux
Action
Dispatcher Store View
Flux
Action
Dispatcher Store View
Let’s see how it
used in UltraStudio
Q&A
1 von 21

Recomendados

React Native +Redux + ES6 (Updated) von
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)Chiew Carol
694 views31 Folien
"How to... React" by Luca Perna von
"How to... React" by Luca Perna"How to... React" by Luca Perna
"How to... React" by Luca PernaThinkOpen
115 views24 Folien
Neoito — React 101 von
Neoito — React 101Neoito — React 101
Neoito — React 101Neoito
119 views16 Folien
Using redux von
Using reduxUsing redux
Using reduxJonas Ohlsson Aden
3.4K views22 Folien
Redux Universal von
Redux UniversalRedux Universal
Redux UniversalNikolaus Graf
1.9K views25 Folien
Better React state management with Redux von
Better React state management with ReduxBetter React state management with Redux
Better React state management with ReduxMaurice De Beijer [MVP]
632 views78 Folien

Más contenido relacionado

Was ist angesagt?

Getting started with Redux js von
Getting started with Redux jsGetting started with Redux js
Getting started with Redux jsCitrix
482 views23 Folien
Designing applications with Redux von
Designing applications with ReduxDesigning applications with Redux
Designing applications with ReduxFernando Daciuk
1.2K views82 Folien
ReactJS for Beginners von
ReactJS for BeginnersReactJS for Beginners
ReactJS for BeginnersOswald Campesato
805 views57 Folien
Intro to Redux | DreamLab Academy #3 von
Intro to Redux | DreamLab Academy #3 Intro to Redux | DreamLab Academy #3
Intro to Redux | DreamLab Academy #3 DreamLab
234 views41 Folien
ComponenKit and React Native von
ComponenKit and React NativeComponenKit and React Native
ComponenKit and React NativeStanfy
1.2K views68 Folien
ReactJs presentation von
ReactJs presentationReactJs presentation
ReactJs presentationnishasowdri
910 views79 Folien

Was ist angesagt?(20)

Getting started with Redux js von Citrix
Getting started with Redux jsGetting started with Redux js
Getting started with Redux js
Citrix482 views
Designing applications with Redux von Fernando Daciuk
Designing applications with ReduxDesigning applications with Redux
Designing applications with Redux
Fernando Daciuk1.2K views
Intro to Redux | DreamLab Academy #3 von DreamLab
Intro to Redux | DreamLab Academy #3 Intro to Redux | DreamLab Academy #3
Intro to Redux | DreamLab Academy #3
DreamLab234 views
ComponenKit and React Native von Stanfy
ComponenKit and React NativeComponenKit and React Native
ComponenKit and React Native
Stanfy1.2K views
ReactJs presentation von nishasowdri
ReactJs presentationReactJs presentation
ReactJs presentation
nishasowdri910 views
Better web apps with React and Redux von Ali Sa'o
Better web apps with React and ReduxBetter web apps with React and Redux
Better web apps with React and Redux
Ali Sa'o203 views
JavaScript, React Native and Performance at react-europe 2016 von Tadeu Zagallo
JavaScript, React Native and Performance at react-europe 2016JavaScript, React Native and Performance at react-europe 2016
JavaScript, React Native and Performance at react-europe 2016
Tadeu Zagallo2.1K views
Creating a WYSIWYG Editor with React von peychevi
Creating a WYSIWYG Editor with ReactCreating a WYSIWYG Editor with React
Creating a WYSIWYG Editor with React
peychevi13.3K views
React.js and Redux overview von Alex Bachuk
React.js and Redux overviewReact.js and Redux overview
React.js and Redux overview
Alex Bachuk565 views
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio) von Binary Studio
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
Binary Studio1.6K views
ReactJS presentation von Thanh Tuong
ReactJS presentationReactJS presentation
ReactJS presentation
Thanh Tuong5.7K views
A Closer Look At React Native von Ian Wang
A Closer Look At React NativeA Closer Look At React Native
A Closer Look At React Native
Ian Wang730 views

Similar a Introduction to ReactJS

Getting Started with React v16 von
Getting Started with React v16Getting Started with React v16
Getting Started with React v16Benny Neugebauer
85 views20 Folien
Build web apps with react js von
Build web apps with react jsBuild web apps with react js
Build web apps with react jsdhanushkacnd
177 views32 Folien
Let's react - Meetup von
Let's react - MeetupLet's react - Meetup
Let's react - MeetupRAJNISH KATHAROTIYA
23 views34 Folien
React - Start learning today von
React - Start learning today React - Start learning today
React - Start learning today Nitin Tyagi
140 views12 Folien
React && React Native workshop von
React && React Native workshopReact && React Native workshop
React && React Native workshopStacy Goh
611 views104 Folien
Connect.js - Exploring React.Native von
Connect.js - Exploring React.NativeConnect.js - Exploring React.Native
Connect.js - Exploring React.Nativejoshcjensen
786 views39 Folien

Similar a Introduction to ReactJS(20)

Build web apps with react js von dhanushkacnd
Build web apps with react jsBuild web apps with react js
Build web apps with react js
dhanushkacnd177 views
React - Start learning today von Nitin Tyagi
React - Start learning today React - Start learning today
React - Start learning today
Nitin Tyagi140 views
React && React Native workshop von Stacy Goh
React && React Native workshopReact && React Native workshop
React && React Native workshop
Stacy Goh611 views
Connect.js - Exploring React.Native von joshcjensen
Connect.js - Exploring React.NativeConnect.js - Exploring React.Native
Connect.js - Exploring React.Native
joshcjensen786 views
React Native Androidはなぜ動くのか von Yukiya Nakagawa
React Native Androidはなぜ動くのかReact Native Androidはなぜ動くのか
React Native Androidはなぜ動くのか
Yukiya Nakagawa11.2K views
Server side rendering with React and Symfony von Ignacio Martín
Server side rendering with React and SymfonyServer side rendering with React and Symfony
Server side rendering with React and Symfony
Ignacio Martín2.8K views
Introduction to React for Frontend Developers von Sergio Nakamura
Introduction to React for Frontend DevelopersIntroduction to React for Frontend Developers
Introduction to React for Frontend Developers
Sergio Nakamura17 views
Introduction to ReactJS von Knoldus Inc.
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
Knoldus Inc.2.3K views
An Emoji Introduction to React Native (Panagiotis Vourtsis, Senior Front End ... von GreeceJS
An Emoji Introduction to React Native (Panagiotis Vourtsis, Senior Front End ...An Emoji Introduction to React Native (Panagiotis Vourtsis, Senior Front End ...
An Emoji Introduction to React Native (Panagiotis Vourtsis, Senior Front End ...
GreeceJS689 views
React mit TypeScript – eine glückliche Ehe von inovex GmbH
React mit TypeScript – eine glückliche EheReact mit TypeScript – eine glückliche Ehe
React mit TypeScript – eine glückliche Ehe
inovex GmbH367 views
Pragmatic introduction to react von Maayan Glikser
Pragmatic introduction to reactPragmatic introduction to react
Pragmatic introduction to react
Maayan Glikser391 views

Más de AdroitLogic

AdroitLogic Integration Platform Server (IPS) Whitepaper von
AdroitLogic Integration Platform Server (IPS) WhitepaperAdroitLogic Integration Platform Server (IPS) Whitepaper
AdroitLogic Integration Platform Server (IPS) WhitepaperAdroitLogic
572 views23 Folien
Software Testing von
Software TestingSoftware Testing
Software TestingAdroitLogic
405 views76 Folien
AdroitLogic UltraESB von
AdroitLogic UltraESBAdroitLogic UltraESB
AdroitLogic UltraESBAdroitLogic
182 views37 Folien
AdroitLogic UltraESB-X von
AdroitLogic UltraESB-XAdroitLogic UltraESB-X
AdroitLogic UltraESB-XAdroitLogic
116 views10 Folien
AS2Gateway and AS2Station von
AS2Gateway and AS2StationAS2Gateway and AS2Station
AS2Gateway and AS2StationAdroitLogic
165 views7 Folien
AdroitLogic Product Portfolio von
AdroitLogic Product PortfolioAdroitLogic Product Portfolio
AdroitLogic Product PortfolioAdroitLogic
480 views40 Folien

Más de AdroitLogic(17)

AdroitLogic Integration Platform Server (IPS) Whitepaper von AdroitLogic
AdroitLogic Integration Platform Server (IPS) WhitepaperAdroitLogic Integration Platform Server (IPS) Whitepaper
AdroitLogic Integration Platform Server (IPS) Whitepaper
AdroitLogic572 views
AdroitLogic UltraESB von AdroitLogic
AdroitLogic UltraESBAdroitLogic UltraESB
AdroitLogic UltraESB
AdroitLogic182 views
AdroitLogic UltraESB-X von AdroitLogic
AdroitLogic UltraESB-XAdroitLogic UltraESB-X
AdroitLogic UltraESB-X
AdroitLogic116 views
AS2Gateway and AS2Station von AdroitLogic
AS2Gateway and AS2StationAS2Gateway and AS2Station
AS2Gateway and AS2Station
AdroitLogic165 views
AdroitLogic Product Portfolio von AdroitLogic
AdroitLogic Product PortfolioAdroitLogic Product Portfolio
AdroitLogic Product Portfolio
AdroitLogic480 views
System Configuration for UltraESB von AdroitLogic
System Configuration for UltraESBSystem Configuration for UltraESB
System Configuration for UltraESB
AdroitLogic878 views
Administration and Management with UltraESB von AdroitLogic
Administration and Management with UltraESBAdministration and Management with UltraESB
Administration and Management with UltraESB
AdroitLogic393 views
Systems management - UltraESB von AdroitLogic
Systems management - UltraESBSystems management - UltraESB
Systems management - UltraESB
AdroitLogic275 views
Getting hands on-experience with UltraESB von AdroitLogic
Getting hands on-experience with UltraESBGetting hands on-experience with UltraESB
Getting hands on-experience with UltraESB
AdroitLogic166 views
ESB vs API management von AdroitLogic
ESB vs API managementESB vs API management
ESB vs API management
AdroitLogic8.8K views
UltraESB - Advanced services von AdroitLogic
UltraESB - Advanced servicesUltraESB - Advanced services
UltraESB - Advanced services
AdroitLogic793 views
UltraESB - Installation and Configuration von AdroitLogic
UltraESB - Installation and ConfigurationUltraESB - Installation and Configuration
UltraESB - Installation and Configuration
AdroitLogic459 views
UltraESB - an introduction von AdroitLogic
UltraESB - an introductionUltraESB - an introduction
UltraESB - an introduction
AdroitLogic203 views
Introduction to AdroitLogic and UltraESB von AdroitLogic
Introduction to AdroitLogic and UltraESBIntroduction to AdroitLogic and UltraESB
Introduction to AdroitLogic and UltraESB
AdroitLogic462 views
WADL support for UltraESB von AdroitLogic
WADL support for UltraESBWADL support for UltraESB
WADL support for UltraESB
AdroitLogic207 views
Monitoring multiple UltraESB instances with UConsole von AdroitLogic
Monitoring multiple UltraESB instances with UConsoleMonitoring multiple UltraESB instances with UConsole
Monitoring multiple UltraESB instances with UConsole
AdroitLogic235 views

Último

SUGCON ANZ Presentation V2.1 Final.pptx von
SUGCON ANZ Presentation V2.1 Final.pptxSUGCON ANZ Presentation V2.1 Final.pptx
SUGCON ANZ Presentation V2.1 Final.pptxJack Spektor
22 views34 Folien
AI and Ml presentation .pptx von
AI and Ml presentation .pptxAI and Ml presentation .pptx
AI and Ml presentation .pptxFayazAli87
11 views15 Folien
SAP FOR TYRE INDUSTRY.pdf von
SAP FOR TYRE INDUSTRY.pdfSAP FOR TYRE INDUSTRY.pdf
SAP FOR TYRE INDUSTRY.pdfVirendra Rai, PMP
24 views3 Folien
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium... von
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...Lisi Hocke
28 views124 Folien
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ... von
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...Donato Onofri
795 views34 Folien
Generic or specific? Making sensible software design decisions von
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsBert Jan Schrijver
6 views60 Folien

Último(20)

SUGCON ANZ Presentation V2.1 Final.pptx von Jack Spektor
SUGCON ANZ Presentation V2.1 Final.pptxSUGCON ANZ Presentation V2.1 Final.pptx
SUGCON ANZ Presentation V2.1 Final.pptx
Jack Spektor22 views
AI and Ml presentation .pptx von FayazAli87
AI and Ml presentation .pptxAI and Ml presentation .pptx
AI and Ml presentation .pptx
FayazAli8711 views
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium... von Lisi Hocke
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Lisi Hocke28 views
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ... von Donato Onofri
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Donato Onofri795 views
Generic or specific? Making sensible software design decisions von Bert Jan Schrijver
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
DSD-INT 2023 Leveraging the results of a 3D hydrodynamic model to improve the... von Deltares
DSD-INT 2023 Leveraging the results of a 3D hydrodynamic model to improve the...DSD-INT 2023 Leveraging the results of a 3D hydrodynamic model to improve the...
DSD-INT 2023 Leveraging the results of a 3D hydrodynamic model to improve the...
Deltares6 views
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko... von Deltares
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...
Deltares14 views
DSD-INT 2023 Simulating a falling apron in Delft3D 4 - Engineering Practice -... von Deltares
DSD-INT 2023 Simulating a falling apron in Delft3D 4 - Engineering Practice -...DSD-INT 2023 Simulating a falling apron in Delft3D 4 - Engineering Practice -...
DSD-INT 2023 Simulating a falling apron in Delft3D 4 - Engineering Practice -...
Deltares6 views
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx von animuscrm
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx
animuscrm14 views
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J... von Deltares
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...
Deltares9 views
Gen Apps on Google Cloud PaLM2 and Codey APIs in Action von Márton Kodok
Gen Apps on Google Cloud PaLM2 and Codey APIs in ActionGen Apps on Google Cloud PaLM2 and Codey APIs in Action
Gen Apps on Google Cloud PaLM2 and Codey APIs in Action
Márton Kodok5 views
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI... von Marc Müller
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...
Marc Müller37 views
DSD-INT 2023 Salt intrusion Modelling of the Lauwersmeer, towards a measureme... von Deltares
DSD-INT 2023 Salt intrusion Modelling of the Lauwersmeer, towards a measureme...DSD-INT 2023 Salt intrusion Modelling of the Lauwersmeer, towards a measureme...
DSD-INT 2023 Salt intrusion Modelling of the Lauwersmeer, towards a measureme...
Deltares5 views
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra... von Marc Müller
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra....NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
Marc Müller38 views

Introduction to ReactJS

  • 2. First Project $ npm install -g create-react-app $ create-react-app hello-world $ cd hello-world $ npm start
  • 3. Let’s see how it really works
  • 4. Components import React, { Component } from 'react'; class App extends Component { render() { return ( <div className="App"> <h1> Hello World </h1> </div> ); } } export default App;
  • 5. React JSXsyntactic-sugar for JS const element = ( <h1 className="greeting"> Hello, world! </h1> ); JSX Code const element = React.createElement( 'h1', {className: 'greeting'}, 'Hello, world!' ); Compiled JS Code • Template Language with full power of JS • Prevents injection attacks https://facebook.github.io/react/docs/introducing-jsx.html more… https://facebook.github.io/react/docs/jsx-in-depth.html
  • 6. State vs.Props •STATE - Specific to a particular component (to track the changes of the component •PROPS - Passed from the parent Component.Inputs to the child component Features STATE PROPS Can get initial value from parent component? Yes Yes Can be directly changed by parent component? No Yes Can set default values inside component? Yes Yes Can change inside component? Yes No Can set initial value for child component? Yes Yes Can change in child component? Yes No
  • 7. Component Events - Mounting • constructor() • componentWillMount() • render() • componentDidMount()
  • 8. Component Events - Updating • componentWillReceiveProps(nextProps) • shouldComponentUpdate(nextProps,nextState) • componentWillUpdate(nextProps,nextState) • render() • componentDidUpdate(prevProps,prevState)
  • 9. Component Events - Unmounting • componentWillUnmount() Instance Properties,API • props • state • setState() • forceUpdate()
  • 10. Virtual DOM User’s View (Real DOM) Background JS Process (Virtual DOM) Initial State
  • 11. Virtual DOM User’s View (Real DOM) Background JS Process (Virtual DOM) First Render <html> <div> <h1>Sajith</h1> </div> </html>
  • 12. Virtual DOM User’s View (Real DOM) Background JS Process (Virtual DOM) Real DOM populated and Virtual DOM cleared <html> <div> <h1>Sajith</h1> </div> </html> <html> <div> <h1>Sajith</h1> </div> </html>
  • 13. Virtual DOM User’s View (Real DOM) Background JS Process (Virtual DOM) Click on Change Me <html> <div> <h1>Sajith</h1> </div> </html> <html> <div> <h1>Dilshan</h1> </div> </html>
  • 14. Virtual DOM User’s View (Real DOM) Background JS Process (Virtual DOM) Only modified section is updated in Real DOM and Virtual DOM is cleared <html> <div> <h1>Dilshan</h1> </div> </html> <html> <div> <h1>Dilshan</h1> </div> </html> <html> <div> <h1>Sajith</h1> </div> </html>
  • 15. Reconciliation • Use “diffing” algorithm • the state of the art algorithms have a complexity in the order of O(n3) where n is the number of elements in the tree. • React implements a heuristic O(n) algorithm https://facebook.github.io/react/docs/reconciliation.html
  • 20. Let’s see how it used in UltraStudio
  • 21. Q&A