SlideShare a Scribd company logo
Welcome to React &
Flux !
by Ritesh
Introduction to ReactJS
Q.) What is React JS ?
● React Js is nothing but a UI library built by Facebook to improve the creation
of interactive, stateful, and reusable UI components.
● One of its unique feature is that it helps us overcome the limitation of DOM
manipulation of browser for an interactive UI by introducing a concept of
virtual DOM that selectively renders subtrees of nodes based upon state
changes.
contd...
● React JS is being used in production by Facebook and sites like Instagram is
entirely converted and built in ReactJS.
● Facebook Chat and message which used to very buggy with notifications on
message not sync is all very smooth all thanks to the ReactJS & Flux.
Features of React JS
● One of the key aspects of ReactJS is that it can be used both on the client-
side as well as on the server side.
● React is build to solve the problem of updating UI of large applications
where data changes over time.
● React is simple, declarative, built of compassable components and yes you
need to give it sometime to get a nice flavour of it.
React at first look !
Now Let us look at first ReactJS code. Need not to worry, we will be covering
them in details shortly. Its just to give you a look and feel of 1st ReactJS
component code.
Now, tell me what you
think of by seeing this
code for the 1st time ?
Probable answers !
If you have worked with JavaScript before which is a prerequisite for this course
you may think like :
a. Isn’t this ugly ?
b. will it not be making things complex by putting Javascript and html in the
same file ?
c. No clue whats going on. Is this javascript ?
d. Is React only templating language ?
Don’t worry :)
The thing is that it’s just JavaScript and it’s not a templating language.
The Code that you see previously is written in JSX which is a JavaScript
extension.
The JSX code increases the efficiency as it performs optimization while
compiling the source code to JavaScript.
Some more Gyan on React !
If you have worked earlier with JavaScript, you would have seen the MVC being
followed which stands for Model View Controller architecture.
In this ReactJS works only with the Views and it doesn’t care about how the data
is passed or handled across the web-application.
This was mostly the architectural problem that is outside the scope of ReactJS
and to overcome that the developers at Facebook proposed a functional
approach which they call as FLUX.
Flux Architecture
contd...
Flux introduced the concept of Actions, Dispatchers & Stores. Mutation of data
can only be done through calling the actions. This architecture allows for the
data flow in a single direction only and hence makes it easier to monitor data
changes affecting the application.
Why React in UI ?
The most basic function of UI is to display some data and React makes it easy to
do that as well as keep the page updated with least DOM mutations to browser.
Now, you all can write a basic React JS code which i display in the next slide and
run your first React code in the browser. Just create a .html file and copy the
code that i show in the next slide.
Run your 1st React Code
contd...
In the code which is presented before you will see that the some data keeps
changing on the page while the others remains as it is.
Here the virtual DOM comes into picture where it does the diff with the new DOM
and renders only the minimum change required.
Since, the code is not in pure javascript it is first compiled using babel. Babel is a
javascript compiler. React and React-DOM library is also imported for developing
in their framework.
More deep into React !
What is JSX ?
● JSX in simple is a language that lets you create javascript object from HTML
syntax which runs faster on the browsers compared to the normal
JavaScript.
● strictly typed OO programming language.
● syntax : class / function definition like JAVA.
● function body is javascript.
● strict type leads to higher productivity than javaScript.
contd...
Few more facts about JSX :
1. The code written in JSX when compiled runs faster than equivalent JS code.
the code is optimised using type info.
2. Compiled code generates source-map for debugging. (* source-map : It is a
technology that supports debugging of client-side code on web-browsers
written in language other than javascript.)
React Components
Components in React :
Components in react can be thought of as a simple function which takes “props”
and “state” as arguments and renders HTML based on that.
Note : React components can render only a single root node. If the requirement
is to return multiple nodes then it must be wrapped in a single root, otherwise the
component will not render.
contd...
The inputs to the components are called “Props”, short for “properties”. Props
are passed as attributes in JSX syntax. “Props” are not changed inside a
component and are treated as immutable objects. The state of the component is
stored in “this.state” of the component.
More of React Gyan!
1. In React, everything is a component. React has no : a) controller b) directives
c) templates d) global event listeners e) no view models etc…It only has
“Components” which once understood makes life really easy and removes
complexities.
For E.g : You have a simple shopping below which is generally made as a
template which contains too much code for all the elements together and the
data is all handled in model and controller. But, if you want the same to be
implemented in React it become pretty much simple and all revolves about the
component.
contd...
The Flipkart “Shopping Cart”
which is shown here can be
broken into CartComponent,
CartListComponent, Buttons
etc.
Components Advantages!
The advantage of Components way is :
1. Composable
2. Reusable
3. Maintainable
4. Testable
React Gyan contd...
2) Reliable Data Display : It has not built in framework. In React any component
can communicate with any other component.
In React there’s a 1-way data flow only. Data is handled from “Parent” to “Child”.
The data is passed as props from parent component to inner component and
accessed as this.props.
“Props” is immutable and “State” is mutable. “State” can become props. Data
flows down with handlers. Events flow up and data flows down.
contd ....
3) Virtual DOM :
a) It’s a pure-javascript, in-memory representation of DOM.
b) render() fires whenever something changes.
c) React modifies the real DOM to match.
d) It’s FAST, PURE & just works !
React Lifecycle Method!
So, some basic questions now. As, i said earlier React works on virtual DOM. So,
how do i access the actual DOM ?
When i come to know that render has happened for the react component ?
The answer lies in REACT lifecycle method. The lifecycle methods are executed
at specific points in React Lifecycle.
contd...
1. componentWillMount : Invoked once, both on the client and server,
immediately before the initial rendering occurs.
2. componentDidMount : Invoked once, only on the client (not on the server),
immediately after the initial rendering occurs.
3. componentWillReceiveProps : Invoked when a component is receiving new
props. This method is not called for the initial render.
4. shouldComponentUpdate : Invoked before rendering when new props or
state are being received. This method is not called for the initial render or
when forceUpdate is used.
contd...
5. componentWillUpdate : Invoked immediately before rendering when new
props or state are being received. This method is not called for the initial render.
6. componentDidUpdate : Invoked immediately after the component's updates
are flushed to the DOM. This method is not called for the initial render.
7. componentWillUnmount : Invoked immediately before a component is
unmounted from the DOM. etc
contd...
componentDidMount: function() {
var element = $(this.getDOMNode());
}
this.getDOMNode() : Actual DOM Node;
Summary
1. one-way data flow keeps complexity under control.
2. Debugging is easy for self-contained components.
3. React library doesn’t dictate too much.
References
https://facebook.github.io/react/docs/getting-started.html

More Related Content

What's hot (20)

PPTX
React JS Interview Question & Answer
Mildain Solutions
 
PDF
React-js
Avi Kedar
 
PPTX
REACT JS COACHING CENTER IN CHANDIGARH
PritamNegi5
 
PPTX
Introduction to react js and reasons to go with react js in 2020
Concetto Labs
 
PPTX
React js, node js & angular js which one is the best for web development
Concetto Labs
 
PPTX
React js Demo Explanation
Rama Krishna Vankam
 
PPTX
Intro to React
Justin Reock
 
PDF
Fundamental concepts of react js
StephieJohn
 
PPTX
learn what React JS is & why we should use React JS .
paradisetechsoftsolutions
 
PPTX
Say Hello to React day2 presentation
Smile Gupta
 
PDF
Implementing auto complete using JQuery
Bhushan Mulmule
 
PPTX
Introduction to React JS
Lohith Goudagere Nagaraj
 
PDF
Learning React - I
Mitch Chen
 
PDF
ReactJS
Hiten Pratap Singh
 
PDF
Getting Started with React-Nathan Smith
TandemSeven
 
ODP
Introduction to ReactJS
Knoldus Inc.
 
PPTX
Web Performance & Latest in React
Talentica Software
 
PPTX
Reactjs workshop
Ahmed rebai
 
PPTX
Asp.Net MVC Intro
Stefano Paluello
 
PDF
Java 10 - Key Note
Nikhil Hiremath
 
React JS Interview Question & Answer
Mildain Solutions
 
React-js
Avi Kedar
 
REACT JS COACHING CENTER IN CHANDIGARH
PritamNegi5
 
Introduction to react js and reasons to go with react js in 2020
Concetto Labs
 
React js, node js & angular js which one is the best for web development
Concetto Labs
 
React js Demo Explanation
Rama Krishna Vankam
 
Intro to React
Justin Reock
 
Fundamental concepts of react js
StephieJohn
 
learn what React JS is & why we should use React JS .
paradisetechsoftsolutions
 
Say Hello to React day2 presentation
Smile Gupta
 
Implementing auto complete using JQuery
Bhushan Mulmule
 
Introduction to React JS
Lohith Goudagere Nagaraj
 
Learning React - I
Mitch Chen
 
Getting Started with React-Nathan Smith
TandemSeven
 
Introduction to ReactJS
Knoldus Inc.
 
Web Performance & Latest in React
Talentica Software
 
Reactjs workshop
Ahmed rebai
 
Asp.Net MVC Intro
Stefano Paluello
 
Java 10 - Key Note
Nikhil Hiremath
 

Similar to Welcome to React & Flux ! (20)

PDF
React js
Rajesh Kolla
 
PPTX
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
Karmanjay Verma
 
PPTX
Dyanaimcs of business and economics unit 2
jpm071712
 
PPTX
ReactJS Code Impact
Raymond McDermott
 
PPTX
Reactjs notes.pptx for web development- tutorial and theory
jobinThomas54
 
PPTX
Introduction to React JS.pptx
SHAIKIRFAN715544
 
PPTX
ReactJS (1)
George Tony
 
PPTX
React - Start learning today
Nitin Tyagi
 
PPTX
Introduction to ReactJS UI Web Dev .pptx
SHAIKIRFAN715544
 
PPTX
[Final] ReactJS presentation
洪 鹏发
 
PPTX
reactJS
Syam Santhosh
 
PDF
Introduction Web Development using ReactJS
ssuser8a1f37
 
PPTX
ReactJS presentation.pptx
DivyanshGupta922023
 
PDF
Intro to react_v2
Feather Knee
 
PDF
React Interview Question PDF By ScholarHat
Scholarhat
 
PPTX
React_Complete.pptx
kamalakantas
 
PDF
React Interview Questions for Noobs or Juniors
Your Study_Buddy
 
PPTX
ReactJS
Ram Murat Sharma
 
PDF
Getting Started with React, When You’re an Angular Developer
Fabrit Global
 
PDF
Tech Talk on ReactJS
Atlogys Technical Consulting
 
React js
Rajesh Kolla
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
Karmanjay Verma
 
Dyanaimcs of business and economics unit 2
jpm071712
 
ReactJS Code Impact
Raymond McDermott
 
Reactjs notes.pptx for web development- tutorial and theory
jobinThomas54
 
Introduction to React JS.pptx
SHAIKIRFAN715544
 
ReactJS (1)
George Tony
 
React - Start learning today
Nitin Tyagi
 
Introduction to ReactJS UI Web Dev .pptx
SHAIKIRFAN715544
 
[Final] ReactJS presentation
洪 鹏发
 
reactJS
Syam Santhosh
 
Introduction Web Development using ReactJS
ssuser8a1f37
 
ReactJS presentation.pptx
DivyanshGupta922023
 
Intro to react_v2
Feather Knee
 
React Interview Question PDF By ScholarHat
Scholarhat
 
React_Complete.pptx
kamalakantas
 
React Interview Questions for Noobs or Juniors
Your Study_Buddy
 
Getting Started with React, When You’re an Angular Developer
Fabrit Global
 
Tech Talk on ReactJS
Atlogys Technical Consulting
 
Ad

Recently uploaded (20)

PDF
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
trjnesjnqg7801
 
PDF
Rapid Mathematics Assessment Score sheet for all Grade levels
DessaCletSantos
 
PDF
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
 
PPTX
Aerobic and Anaerobic respiration and CPR.pptx
Olivier Rochester
 
PPTX
How to Configure Taxes in Company Currency in Odoo 18 Accounting
Celine George
 
PPTX
Lesson 1 Cell (Structures, Functions, and Theory).pptx
marvinnbustamante1
 
PDF
Lesson 1 : Science and the Art of Geography Ecosystem
marvinnbustamante1
 
PPTX
How to Create & Manage Stages in Odoo 18 Helpdesk
Celine George
 
PPTX
Iván Bornacelly - Presentation of the report - Empowering the workforce in th...
EduSkills OECD
 
PDF
TechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.06.25.pdf
TechSoup
 
PDF
Learning Styles Inventory for Senior High School Students
Thelma Villaflores
 
PPTX
SYMPATHOMIMETICS[ADRENERGIC AGONISTS] pptx
saip95568
 
PPT
21st Century Literature from the Philippines and the World QUARTER 1/ MODULE ...
isaacmendoza76
 
PPTX
How to Manage Wins & Losses in Odoo 18 CRM
Celine George
 
PDF
Genomics Proteomics and Vaccines 1st Edition Guido Grandi (Editor)
kboqcyuw976
 
PPTX
Connecting Linear and Angular Quantities in Human Movement.pptx
AngeliqueTolentinoDe
 
DOCX
Lesson 1 - Nature and Inquiry of Research
marvinnbustamante1
 
PDF
Our Guide to the July 2025 USPS® Rate Change
Postal Advocate Inc.
 
PDF
TLE 8 QUARTER 1 MODULE WEEK 1 MATATAG CURRICULUM
denniseraya1997
 
PPTX
Comparing Translational and Rotational Motion.pptx
AngeliqueTolentinoDe
 
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
trjnesjnqg7801
 
Rapid Mathematics Assessment Score sheet for all Grade levels
DessaCletSantos
 
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
 
Aerobic and Anaerobic respiration and CPR.pptx
Olivier Rochester
 
How to Configure Taxes in Company Currency in Odoo 18 Accounting
Celine George
 
Lesson 1 Cell (Structures, Functions, and Theory).pptx
marvinnbustamante1
 
Lesson 1 : Science and the Art of Geography Ecosystem
marvinnbustamante1
 
How to Create & Manage Stages in Odoo 18 Helpdesk
Celine George
 
Iván Bornacelly - Presentation of the report - Empowering the workforce in th...
EduSkills OECD
 
TechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.06.25.pdf
TechSoup
 
Learning Styles Inventory for Senior High School Students
Thelma Villaflores
 
SYMPATHOMIMETICS[ADRENERGIC AGONISTS] pptx
saip95568
 
21st Century Literature from the Philippines and the World QUARTER 1/ MODULE ...
isaacmendoza76
 
How to Manage Wins & Losses in Odoo 18 CRM
Celine George
 
Genomics Proteomics and Vaccines 1st Edition Guido Grandi (Editor)
kboqcyuw976
 
Connecting Linear and Angular Quantities in Human Movement.pptx
AngeliqueTolentinoDe
 
Lesson 1 - Nature and Inquiry of Research
marvinnbustamante1
 
Our Guide to the July 2025 USPS® Rate Change
Postal Advocate Inc.
 
TLE 8 QUARTER 1 MODULE WEEK 1 MATATAG CURRICULUM
denniseraya1997
 
Comparing Translational and Rotational Motion.pptx
AngeliqueTolentinoDe
 
Ad

Welcome to React & Flux !

  • 1. Welcome to React & Flux ! by Ritesh
  • 2. Introduction to ReactJS Q.) What is React JS ? ● React Js is nothing but a UI library built by Facebook to improve the creation of interactive, stateful, and reusable UI components. ● One of its unique feature is that it helps us overcome the limitation of DOM manipulation of browser for an interactive UI by introducing a concept of virtual DOM that selectively renders subtrees of nodes based upon state changes.
  • 3. contd... ● React JS is being used in production by Facebook and sites like Instagram is entirely converted and built in ReactJS. ● Facebook Chat and message which used to very buggy with notifications on message not sync is all very smooth all thanks to the ReactJS & Flux.
  • 4. Features of React JS ● One of the key aspects of ReactJS is that it can be used both on the client- side as well as on the server side. ● React is build to solve the problem of updating UI of large applications where data changes over time. ● React is simple, declarative, built of compassable components and yes you need to give it sometime to get a nice flavour of it.
  • 5. React at first look ! Now Let us look at first ReactJS code. Need not to worry, we will be covering them in details shortly. Its just to give you a look and feel of 1st ReactJS component code. Now, tell me what you think of by seeing this code for the 1st time ?
  • 6. Probable answers ! If you have worked with JavaScript before which is a prerequisite for this course you may think like : a. Isn’t this ugly ? b. will it not be making things complex by putting Javascript and html in the same file ? c. No clue whats going on. Is this javascript ? d. Is React only templating language ?
  • 7. Don’t worry :) The thing is that it’s just JavaScript and it’s not a templating language. The Code that you see previously is written in JSX which is a JavaScript extension. The JSX code increases the efficiency as it performs optimization while compiling the source code to JavaScript.
  • 8. Some more Gyan on React ! If you have worked earlier with JavaScript, you would have seen the MVC being followed which stands for Model View Controller architecture. In this ReactJS works only with the Views and it doesn’t care about how the data is passed or handled across the web-application. This was mostly the architectural problem that is outside the scope of ReactJS and to overcome that the developers at Facebook proposed a functional approach which they call as FLUX.
  • 10. contd... Flux introduced the concept of Actions, Dispatchers & Stores. Mutation of data can only be done through calling the actions. This architecture allows for the data flow in a single direction only and hence makes it easier to monitor data changes affecting the application.
  • 11. Why React in UI ? The most basic function of UI is to display some data and React makes it easy to do that as well as keep the page updated with least DOM mutations to browser. Now, you all can write a basic React JS code which i display in the next slide and run your first React code in the browser. Just create a .html file and copy the code that i show in the next slide.
  • 12. Run your 1st React Code
  • 13. contd... In the code which is presented before you will see that the some data keeps changing on the page while the others remains as it is. Here the virtual DOM comes into picture where it does the diff with the new DOM and renders only the minimum change required. Since, the code is not in pure javascript it is first compiled using babel. Babel is a javascript compiler. React and React-DOM library is also imported for developing in their framework.
  • 14. More deep into React ! What is JSX ? ● JSX in simple is a language that lets you create javascript object from HTML syntax which runs faster on the browsers compared to the normal JavaScript. ● strictly typed OO programming language. ● syntax : class / function definition like JAVA. ● function body is javascript. ● strict type leads to higher productivity than javaScript.
  • 15. contd... Few more facts about JSX : 1. The code written in JSX when compiled runs faster than equivalent JS code. the code is optimised using type info. 2. Compiled code generates source-map for debugging. (* source-map : It is a technology that supports debugging of client-side code on web-browsers written in language other than javascript.)
  • 16. React Components Components in React : Components in react can be thought of as a simple function which takes “props” and “state” as arguments and renders HTML based on that. Note : React components can render only a single root node. If the requirement is to return multiple nodes then it must be wrapped in a single root, otherwise the component will not render.
  • 17. contd... The inputs to the components are called “Props”, short for “properties”. Props are passed as attributes in JSX syntax. “Props” are not changed inside a component and are treated as immutable objects. The state of the component is stored in “this.state” of the component.
  • 18. More of React Gyan! 1. In React, everything is a component. React has no : a) controller b) directives c) templates d) global event listeners e) no view models etc…It only has “Components” which once understood makes life really easy and removes complexities. For E.g : You have a simple shopping below which is generally made as a template which contains too much code for all the elements together and the data is all handled in model and controller. But, if you want the same to be implemented in React it become pretty much simple and all revolves about the component.
  • 19. contd... The Flipkart “Shopping Cart” which is shown here can be broken into CartComponent, CartListComponent, Buttons etc.
  • 20. Components Advantages! The advantage of Components way is : 1. Composable 2. Reusable 3. Maintainable 4. Testable
  • 21. React Gyan contd... 2) Reliable Data Display : It has not built in framework. In React any component can communicate with any other component. In React there’s a 1-way data flow only. Data is handled from “Parent” to “Child”. The data is passed as props from parent component to inner component and accessed as this.props. “Props” is immutable and “State” is mutable. “State” can become props. Data flows down with handlers. Events flow up and data flows down.
  • 22. contd .... 3) Virtual DOM : a) It’s a pure-javascript, in-memory representation of DOM. b) render() fires whenever something changes. c) React modifies the real DOM to match. d) It’s FAST, PURE & just works !
  • 23. React Lifecycle Method! So, some basic questions now. As, i said earlier React works on virtual DOM. So, how do i access the actual DOM ? When i come to know that render has happened for the react component ? The answer lies in REACT lifecycle method. The lifecycle methods are executed at specific points in React Lifecycle.
  • 24. contd... 1. componentWillMount : Invoked once, both on the client and server, immediately before the initial rendering occurs. 2. componentDidMount : Invoked once, only on the client (not on the server), immediately after the initial rendering occurs. 3. componentWillReceiveProps : Invoked when a component is receiving new props. This method is not called for the initial render. 4. shouldComponentUpdate : Invoked before rendering when new props or state are being received. This method is not called for the initial render or when forceUpdate is used.
  • 25. contd... 5. componentWillUpdate : Invoked immediately before rendering when new props or state are being received. This method is not called for the initial render. 6. componentDidUpdate : Invoked immediately after the component's updates are flushed to the DOM. This method is not called for the initial render. 7. componentWillUnmount : Invoked immediately before a component is unmounted from the DOM. etc
  • 26. contd... componentDidMount: function() { var element = $(this.getDOMNode()); } this.getDOMNode() : Actual DOM Node;
  • 27. Summary 1. one-way data flow keeps complexity under control. 2. Debugging is easy for self-contained components. 3. React library doesn’t dictate too much.