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

React JS Interview Question & Answer
React JS Interview Question & AnswerReact JS Interview Question & Answer
React JS Interview Question & Answer
Mildain Solutions
 
React-js
React-jsReact-js
React-js
Avi Kedar
 
REACT JS COACHING CENTER IN CHANDIGARH
REACT JS COACHING CENTER IN CHANDIGARHREACT JS COACHING CENTER IN CHANDIGARH
REACT JS COACHING CENTER IN CHANDIGARH
PritamNegi5
 
Introduction to react js and reasons to go with react js in 2020
Introduction to react js and reasons to go with react js in 2020Introduction to react js and reasons to go with react js in 2020
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
React js, node js & angular js  which one is the best for web development React js, node js & angular js  which one is the best for web development
React js, node js & angular js which one is the best for web development
Concetto Labs
 
React js Demo Explanation
React js Demo ExplanationReact js Demo Explanation
React js Demo Explanation
Rama Krishna Vankam
 
Intro to React
Intro to ReactIntro to React
Intro to React
Justin Reock
 
Fundamental concepts of react js
Fundamental concepts of react jsFundamental concepts of react js
Fundamental concepts of react js
StephieJohn
 
learn what React JS is & why we should use React JS .
learn what React JS is & why we should use React JS .learn what React JS is & why we should use React JS .
learn what React JS is & why we should use React JS .
paradisetechsoftsolutions
 
Say Hello to React day2 presentation
Say Hello to React   day2 presentationSay Hello to React   day2 presentation
Say Hello to React day2 presentation
Smile Gupta
 
Implementing auto complete using JQuery
Implementing auto complete using JQueryImplementing auto complete using JQuery
Implementing auto complete using JQuery
Bhushan Mulmule
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
Lohith Goudagere Nagaraj
 
Learning React - I
Learning React - ILearning React - I
Learning React - I
Mitch Chen
 
ReactJS
ReactJSReactJS
Getting Started with React-Nathan Smith
Getting Started with React-Nathan SmithGetting Started with React-Nathan Smith
Getting Started with React-Nathan Smith
TandemSeven
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
Knoldus Inc.
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in React
Talentica Software
 
Reactjs workshop
Reactjs workshop Reactjs workshop
Reactjs workshop
Ahmed rebai
 
Asp.Net MVC Intro
Asp.Net MVC IntroAsp.Net MVC Intro
Asp.Net MVC Intro
Stefano Paluello
 
Java 10 - Key Note
Java 10 - Key NoteJava 10 - Key Note
Java 10 - Key Note
Nikhil Hiremath
 

What's hot (20)

React JS Interview Question & Answer
React JS Interview Question & AnswerReact JS Interview Question & Answer
React JS Interview Question & Answer
 
React-js
React-jsReact-js
React-js
 
REACT JS COACHING CENTER IN CHANDIGARH
REACT JS COACHING CENTER IN CHANDIGARHREACT JS COACHING CENTER IN CHANDIGARH
REACT JS COACHING CENTER IN CHANDIGARH
 
Introduction to react js and reasons to go with react js in 2020
Introduction to react js and reasons to go with react js in 2020Introduction to react js and reasons to go with react js in 2020
Introduction to react js and reasons to go with react js in 2020
 
React js, node js & angular js which one is the best for web development
React js, node js & angular js  which one is the best for web development React js, node js & angular js  which one is the best for web development
React js, node js & angular js which one is the best for web development
 
React js Demo Explanation
React js Demo ExplanationReact js Demo Explanation
React js Demo Explanation
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
Fundamental concepts of react js
Fundamental concepts of react jsFundamental concepts of react js
Fundamental concepts of react js
 
learn what React JS is & why we should use React JS .
learn what React JS is & why we should use React JS .learn what React JS is & why we should use React JS .
learn what React JS is & why we should use React JS .
 
Say Hello to React day2 presentation
Say Hello to React   day2 presentationSay Hello to React   day2 presentation
Say Hello to React day2 presentation
 
Implementing auto complete using JQuery
Implementing auto complete using JQueryImplementing auto complete using JQuery
Implementing auto complete using JQuery
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
 
Learning React - I
Learning React - ILearning React - I
Learning React - I
 
ReactJS
ReactJSReactJS
ReactJS
 
Getting Started with React-Nathan Smith
Getting Started with React-Nathan SmithGetting Started with React-Nathan Smith
Getting Started with React-Nathan Smith
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in React
 
Reactjs workshop
Reactjs workshop Reactjs workshop
Reactjs workshop
 
Asp.Net MVC Intro
Asp.Net MVC IntroAsp.Net MVC Intro
Asp.Net MVC Intro
 
Java 10 - Key Note
Java 10 - Key NoteJava 10 - Key Note
Java 10 - Key Note
 

Similar to Welcome to React & Flux !

Tech Talk on ReactJS
Tech Talk on ReactJSTech Talk on ReactJS
Tech Talk on ReactJS
Atlogys Technical Consulting
 
Techpaathshala ReactJS .pdf
Techpaathshala ReactJS .pdfTechpaathshala ReactJS .pdf
Techpaathshala ReactJS .pdf
Techpaathshala
 
Better web apps with React and Redux
Better web apps with React and ReduxBetter web apps with React and Redux
Better web apps with React and Redux
Ali Sa'o
 
Rethinking Best Practices
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practices
floydophone
 
JOSA TechTalks - Better Web Apps with React and Redux
JOSA TechTalks - Better Web Apps with React and ReduxJOSA TechTalks - Better Web Apps with React and Redux
JOSA TechTalks - Better Web Apps with React and Redux
Jordan Open Source Association
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
GDSC UofT Mississauga
 
FRONTEND DEVELOPMENT WITH REACT.JS
FRONTEND DEVELOPMENT WITH REACT.JSFRONTEND DEVELOPMENT WITH REACT.JS
FRONTEND DEVELOPMENT WITH REACT.JS
IRJET Journal
 
Reactjs notes.pptx for web development- tutorial and theory
Reactjs  notes.pptx for web development- tutorial and theoryReactjs  notes.pptx for web development- tutorial and theory
Reactjs notes.pptx for web development- tutorial and theory
jobinThomas54
 
React JS: A Secret Preview
React JS: A Secret PreviewReact JS: A Secret Preview
React JS: A Secret Preview
valuebound
 
Introduction to React JS.pptx
Introduction to React JS.pptxIntroduction to React JS.pptx
Introduction to React JS.pptx
SHAIKIRFAN715544
 
React DOM/Virtual DOM
React DOM/Virtual DOMReact DOM/Virtual DOM
React DOM/Virtual DOM
RajasreePothula3
 
Introduction to ReactJS UI Web Dev .pptx
Introduction to ReactJS UI Web Dev .pptxIntroduction to ReactJS UI Web Dev .pptx
Introduction to ReactJS UI Web Dev .pptx
SHAIKIRFAN715544
 
React gsg presentation with ryan jung & elias malik
React   gsg presentation with ryan jung & elias malikReact   gsg presentation with ryan jung & elias malik
React gsg presentation with ryan jung & elias malik
Lama K Banna
 
Why Should You Choose ReactJS for Game Development_.pdf
Why Should You Choose ReactJS for Game Development_.pdfWhy Should You Choose ReactJS for Game Development_.pdf
Why Should You Choose ReactJS for Game Development_.pdf
ReactJS
 
Learn reactjs, how to code with example and general understanding thinkwik
Learn reactjs, how to code with example and general understanding   thinkwikLearn reactjs, how to code with example and general understanding   thinkwik
Learn reactjs, how to code with example and general understanding thinkwik
Hetaxi patel
 
Copy of React_JS_Notes.pdf
Copy of React_JS_Notes.pdfCopy of React_JS_Notes.pdf
Copy of React_JS_Notes.pdf
suryanarayana272799
 
Frontend Development Bootcamp - React [Online & Offline] In Bangla
Frontend Development Bootcamp - React [Online & Offline] In BanglaFrontend Development Bootcamp - React [Online & Offline] In Bangla
Frontend Development Bootcamp - React [Online & Offline] In Bangla
Stack Learner
 
learn mvc project in 7 day
learn mvc project in 7 daylearn mvc project in 7 day
learn mvc project in 7 day
Quach Long
 
Reactjs
ReactjsReactjs
Skill practical javascript diy projects
Skill practical javascript diy projectsSkill practical javascript diy projects
Skill practical javascript diy projects
SkillPracticalEdTech
 

Similar to Welcome to React & Flux ! (20)

Tech Talk on ReactJS
Tech Talk on ReactJSTech Talk on ReactJS
Tech Talk on ReactJS
 
Techpaathshala ReactJS .pdf
Techpaathshala ReactJS .pdfTechpaathshala ReactJS .pdf
Techpaathshala ReactJS .pdf
 
Better web apps with React and Redux
Better web apps with React and ReduxBetter web apps with React and Redux
Better web apps with React and Redux
 
Rethinking Best Practices
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practices
 
JOSA TechTalks - Better Web Apps with React and Redux
JOSA TechTalks - Better Web Apps with React and ReduxJOSA TechTalks - Better Web Apps with React and Redux
JOSA TechTalks - Better Web Apps with React and Redux
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
 
FRONTEND DEVELOPMENT WITH REACT.JS
FRONTEND DEVELOPMENT WITH REACT.JSFRONTEND DEVELOPMENT WITH REACT.JS
FRONTEND DEVELOPMENT WITH REACT.JS
 
Reactjs notes.pptx for web development- tutorial and theory
Reactjs  notes.pptx for web development- tutorial and theoryReactjs  notes.pptx for web development- tutorial and theory
Reactjs notes.pptx for web development- tutorial and theory
 
React JS: A Secret Preview
React JS: A Secret PreviewReact JS: A Secret Preview
React JS: A Secret Preview
 
Introduction to React JS.pptx
Introduction to React JS.pptxIntroduction to React JS.pptx
Introduction to React JS.pptx
 
React DOM/Virtual DOM
React DOM/Virtual DOMReact DOM/Virtual DOM
React DOM/Virtual DOM
 
Introduction to ReactJS UI Web Dev .pptx
Introduction to ReactJS UI Web Dev .pptxIntroduction to ReactJS UI Web Dev .pptx
Introduction to ReactJS UI Web Dev .pptx
 
React gsg presentation with ryan jung & elias malik
React   gsg presentation with ryan jung & elias malikReact   gsg presentation with ryan jung & elias malik
React gsg presentation with ryan jung & elias malik
 
Why Should You Choose ReactJS for Game Development_.pdf
Why Should You Choose ReactJS for Game Development_.pdfWhy Should You Choose ReactJS for Game Development_.pdf
Why Should You Choose ReactJS for Game Development_.pdf
 
Learn reactjs, how to code with example and general understanding thinkwik
Learn reactjs, how to code with example and general understanding   thinkwikLearn reactjs, how to code with example and general understanding   thinkwik
Learn reactjs, how to code with example and general understanding thinkwik
 
Copy of React_JS_Notes.pdf
Copy of React_JS_Notes.pdfCopy of React_JS_Notes.pdf
Copy of React_JS_Notes.pdf
 
Frontend Development Bootcamp - React [Online & Offline] In Bangla
Frontend Development Bootcamp - React [Online & Offline] In BanglaFrontend Development Bootcamp - React [Online & Offline] In Bangla
Frontend Development Bootcamp - React [Online & Offline] In Bangla
 
learn mvc project in 7 day
learn mvc project in 7 daylearn mvc project in 7 day
learn mvc project in 7 day
 
Reactjs
ReactjsReactjs
Reactjs
 
Skill practical javascript diy projects
Skill practical javascript diy projectsSkill practical javascript diy projects
Skill practical javascript diy projects
 

Recently uploaded

The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 

Recently uploaded (20)

The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 

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.