SlideShare a Scribd company logo
React.js
- DURGESH VAISHNAV
ECMAScript 6 (ES6)
/ ECMAScript 2015 (ES2015)
const addition = (arg1, arg2) => arg1 + arg2;
OR
const addition = (arg1, arg2) => {
return arg1 + arg2;
}
More ….
 Block scope
– (let and const)
 Destructuring
- let [a, b] = [10, 20];
 Template String
let fullName = `${firstName} ${lastName}`
 Arrow function
let square = x => x * x;
What is React.js
 A java script library for building user interface. Render UI and responds to events.
 Declarative view for more predictable and easy to debug code.
 Component based for reusability.
 Building Components not templates
 Semantically, it is nothing but HTML and java script.
 Compare to other framework, it has full expressive power of java script.
Separation of Concerns
 Reduce coupling and increase cohesion.
 In Traditional MVC pattern, Controller, ModelView and View are coupled, when you
change one, you might need to change other.
Traditional Performance Best Practices
 Avoid expensive Document Object Model (DOM) operation
 Minimize access to the DOM
 Update elements offline before reinserting into the DOM
 Avoid tweaking HTML layouts in Java script
React Re-render
 React is using Virtual DOM to re-render every thing on every update.
 Not expensive, How?
 Create lightweight description of UI component.
 Diff it with the old one.
 Compute minimal set of changes to apply to the DOM.
 Batch execute all updates
 Benefit
 Clean
 Fast
How React Works
It is fast because it compute minimal DOM operation and batch read and
write.
App
State/
event
React
Component (UI)
Virtual DOM Compute DOM
operations Browser
Virtual DOM
Java script Extension (JSX)
 Initialization
 const element = <h1>Hello, world!</h1>;
 Embedding Expression
 const element = ( <h1> Hello, {formatName(user)}! </h1> );
 const element = <img src={user.avatarUrl}></img>;
 Child Node
 const element
= (<div>
<h1>Hello!</h1>
<h2>Good to see you here.</h2>
</div> );
 (Tip) Must use capitalized variable for Type at Runtime
function Story(props) {
const SpecificStory = components[props.storyType];
return <SpecificStory story={props.story} />;
}
Props vs State
 Both props and state are plain JS objects
 Both props and state changes trigger a render update
 Both props and state are deterministic
 Props are a component configuration and it’s options, but state starts with
default value when component mounts.
 Props are immutable but state suffer from mutation in time (from user
events)
 Component always receive Props but manage their own state.
Stateful component
 Do not modify state directly
 // Wrong
this.state.comment = 'Hello';
 // Correct
 this.setState({comment: 'Hello'});
 State updates may be asynchronous, so use prevState
 // Wrong
this.setState({ counter: this.state.counter + this.props.increment, });
 // Correct
this.setState((prevState, props) => ({ counter: prevState.counter + props.increment }));
 State updates are merged into default state.
fetchPosts().then(response => { this.setState({ posts: response.posts }); });
fetchComments().then(response => { this.setState({ comments: response.comments });
 The data flows down (parent component -> child component), so state can be pass to
child component as props
Containment/Nested Component
function FancyBorder(props) {
return ( <div className={'FancyBorder FancyBorder-' + props.color}> {props.children} </div> );
}
function WelcomeDialog() {
return ( <FancyBorder color="blue">
<h1 className="Dialog-title"> Welcome </h1>
<p className="Dialog-message"> Thank you for visiting our spacecraft! </p>
</FancyBorder> );
}
Here anything inside the <FancyBorder> JSX tag (h1 and p) gets passed into the
FancyBorder component as a children prop. Since FancyBorder renders {props.children}
inside a <div>, the passed elements appear in the final output.
If/Else
const Grade = ({marks} => {
let level;
if(marks > 90) {
level = (<span>A</span>);
} else {
level = (<span>B</span>);
}
return (<div>{level}</div>);
})
<Grade marks={94}/>
Loop
const CountryNames = ({countries} => {
return (<ul>
{countries.map((country) => {
return <li>{country.name}</li>;
})}
</ul>);
})
const countries = [{name: ‘USA’, name: ‘India’}] ;
<CountryNames countries={countries} />
Thinking In React
 Start with UI Mock and Break up UI into a Component Hierarchy, Try out
single responsibility principle, that is, a component should ideally only do
one thing. If it ends up growing, it should be decomposed into smaller
subcomponents.
 Build a static (Dump) version in React
 Identify The Minimal (but complete) Representation Of UI State,
Rules
 All React components must act like pure functions with respect to their
props.
 User-Defined Components Must Be Capitalized
 React Must Be in Scope (Import before using)
 Consider DRY: Don't Repeat Yourself.
What is Redux?
 Redux is a predictable state container for JavaScript apps
 Or Redux allows you to manage the state with a minimal API but
completely predictable behavior.
 Basic Idea
 (prevState, action) => newState
Three Principles of Redux
 Single source of truth - The state of your whole application is stored in an
object tree within a single store.
 State is read-only - The only way to change the state is to emit an action,
an object describing what happened.
 Changes are made with pure functions - To specify how the state tree is
transformed by actions, you write pure reducers.
How Redux Works
Actions/Action Creator
 Actions are payloads of information that send data from your application
to your store.
const ADD_TODO = 'ADD_TODO'
 Action creators are exactly that—functions that create actions.
function addTodo(text) {
return {
type: ADD_TODO,
text
}
}
Reducers
 Reducers specify how the application’s state changes in response with
some action happend.
 (previousState, action) => newState
 Reducer functions are called by the “Container” containers when there is a
user action
 If the reducer changes the state, Redux passes the new state to each
component and React re-renders each component
Store
The Store is the object that brings actions and reducers together. The store
has the following responsibilities:
 Holds application state;
 Allows access to state via getState();
 Allows state to be updated via dispatch(action);
 Registers listeners via subscribe(listener);
 Handles unregistering of listeners via the function returned by
subscribe(listener).
How to use Redux
 List State and Actions for each React Component
 Create Action Creators for each action
 Write Reducers for each Action
 Create Container Component for selected Component
 And defined Store to hold application state and attached all togather.
React Developer Tool
Installation
 npm install -g create-react-app
 create-react-app hello-world
 cd hello-world
 npm start
Question?
Thank you
Ad

More Related Content

What's hot (20)

React lecture
React lectureReact lecture
React lecture
Christoffer Noring
 
Intro to React
Intro to ReactIntro to React
Intro to React
Justin Reock
 
DevNetCreate Workshop - build a react app - React crash course
DevNetCreate Workshop - build a react app - React crash courseDevNetCreate Workshop - build a react app - React crash course
DevNetCreate Workshop - build a react app - React crash course
Cisco DevNet
 
Intro to React
Intro to ReactIntro to React
Intro to React
Eric Westfall
 
Introduction to React JS for beginners | Namespace IT
Introduction to React JS for beginners | Namespace ITIntroduction to React JS for beginners | Namespace IT
Introduction to React JS for beginners | Namespace IT
namespaceit
 
React JS - Introduction
React JS - IntroductionReact JS - Introduction
React JS - Introduction
Sergey Romaneko
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
Nikolaus Graf
 
React web development
React web developmentReact web development
React web development
Rully Ramanda
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
Arnold Asllani
 
ReactJS
ReactJSReactJS
ReactJS
Hiten Pratap Singh
 
React js
React jsReact js
React js
Jai Santhosh
 
ReactJS presentation
ReactJS presentationReactJS presentation
ReactJS presentation
Thanh Tuong
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
Knoldus Inc.
 
React JS - A quick introduction tutorial
React JS - A quick introduction tutorialReact JS - A quick introduction tutorial
React JS - A quick introduction tutorial
Mohammed Fazuluddin
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation
洪 鹏发
 
Learn react-js
Learn react-jsLearn react-js
Learn react-js
C...L, NESPRESSO, WAFAASSURANCE, SOFRECOM ORANGE
 
React js
React jsReact js
React js
Rajesh Kolla
 
Its time to React.js
Its time to React.jsIts time to React.js
Its time to React.js
Ritesh Mehrotra
 
React js
React jsReact js
React js
Oswald Campesato
 
React Native
React NativeReact Native
React Native
Fatih Şimşek
 

Viewers also liked (17)

React JS and why it's awesome
React JS and why it's awesomeReact JS and why it's awesome
React JS and why it's awesome
Andrew Hull
 
CV-S Building Project Presentation
CV-S Building Project PresentationCV-S Building Project Presentation
CV-S Building Project Presentation
Steve Schneider
 
Intro to React - Featuring Modern JavaScript
Intro to React - Featuring Modern JavaScriptIntro to React - Featuring Modern JavaScript
Intro to React - Featuring Modern JavaScript
jasonsich
 
Understanding Facebook's React.js
Understanding Facebook's React.jsUnderstanding Facebook's React.js
Understanding Facebook's React.js
Federico Torre
 
RailsでReact.jsを動かしてみた話
RailsでReact.jsを動かしてみた話RailsでReact.jsを動かしてみた話
RailsでReact.jsを動かしてみた話
yoshioka_cb
 
React js - Component specs and lifecycle
React js - Component specs and lifecycleReact js - Component specs and lifecycle
React js - Component specs and lifecycle
Doanh PHAM
 
Building construction i project 1 report
Building construction i project 1 reportBuilding construction i project 1 report
Building construction i project 1 report
Samanthalee96
 
Building Construction Project 01 Final Report
Building Construction Project 01 Final ReportBuilding Construction Project 01 Final Report
Building Construction Project 01 Final Report
jolynnTJL
 
PROJECT 1 (BUILDING CONSTRUCTION 1)
PROJECT 1 (BUILDING CONSTRUCTION 1)PROJECT 1 (BUILDING CONSTRUCTION 1)
PROJECT 1 (BUILDING CONSTRUCTION 1)
Crysmond Goh
 
Intro to React.js
Intro to React.jsIntro to React.js
Intro to React.js
Smita Prasad
 
Building Construction Project 1
Building Construction Project 1Building Construction Project 1
Building Construction Project 1
Alexander Chung
 
An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.js
Emanuele DelBono
 
Building Construction, Project Planning and Project Management (Level 100 Pro...
Building Construction, Project Planning and Project Management (Level 100 Pro...Building Construction, Project Planning and Project Management (Level 100 Pro...
Building Construction, Project Planning and Project Management (Level 100 Pro...
Akhona Siyabulela Stuurman
 
High rise building construction
High rise building constructionHigh rise building construction
High rise building construction
Construction Tech. and Mgmt., VNIT Nagpur
 
High-rise structural systems
High-rise structural systemsHigh-rise structural systems
High-rise structural systems
Akshay Revekar
 
Building construction-report (1)
Building construction-report (1)Building construction-report (1)
Building construction-report (1)
Soh Shing
 
Internship Report on Building Construction
Internship Report on Building ConstructionInternship Report on Building Construction
Internship Report on Building Construction
Esmael Aragaw
 
React JS and why it's awesome
React JS and why it's awesomeReact JS and why it's awesome
React JS and why it's awesome
Andrew Hull
 
CV-S Building Project Presentation
CV-S Building Project PresentationCV-S Building Project Presentation
CV-S Building Project Presentation
Steve Schneider
 
Intro to React - Featuring Modern JavaScript
Intro to React - Featuring Modern JavaScriptIntro to React - Featuring Modern JavaScript
Intro to React - Featuring Modern JavaScript
jasonsich
 
Understanding Facebook's React.js
Understanding Facebook's React.jsUnderstanding Facebook's React.js
Understanding Facebook's React.js
Federico Torre
 
RailsでReact.jsを動かしてみた話
RailsでReact.jsを動かしてみた話RailsでReact.jsを動かしてみた話
RailsでReact.jsを動かしてみた話
yoshioka_cb
 
React js - Component specs and lifecycle
React js - Component specs and lifecycleReact js - Component specs and lifecycle
React js - Component specs and lifecycle
Doanh PHAM
 
Building construction i project 1 report
Building construction i project 1 reportBuilding construction i project 1 report
Building construction i project 1 report
Samanthalee96
 
Building Construction Project 01 Final Report
Building Construction Project 01 Final ReportBuilding Construction Project 01 Final Report
Building Construction Project 01 Final Report
jolynnTJL
 
PROJECT 1 (BUILDING CONSTRUCTION 1)
PROJECT 1 (BUILDING CONSTRUCTION 1)PROJECT 1 (BUILDING CONSTRUCTION 1)
PROJECT 1 (BUILDING CONSTRUCTION 1)
Crysmond Goh
 
Building Construction Project 1
Building Construction Project 1Building Construction Project 1
Building Construction Project 1
Alexander Chung
 
An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.js
Emanuele DelBono
 
Building Construction, Project Planning and Project Management (Level 100 Pro...
Building Construction, Project Planning and Project Management (Level 100 Pro...Building Construction, Project Planning and Project Management (Level 100 Pro...
Building Construction, Project Planning and Project Management (Level 100 Pro...
Akhona Siyabulela Stuurman
 
High-rise structural systems
High-rise structural systemsHigh-rise structural systems
High-rise structural systems
Akshay Revekar
 
Building construction-report (1)
Building construction-report (1)Building construction-report (1)
Building construction-report (1)
Soh Shing
 
Internship Report on Building Construction
Internship Report on Building ConstructionInternship Report on Building Construction
Internship Report on Building Construction
Esmael Aragaw
 
Ad

Similar to React/Redux (20)

Reactивная тяга
Reactивная тягаReactивная тяга
Reactивная тяга
Vitebsk Miniq
 
ReactJS
ReactJSReactJS
ReactJS
Ram Murat Sharma
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners
Varun Raj
 
React & Redux for noobs
React & Redux for noobsReact & Redux for noobs
React & Redux for noobs
[T]echdencias
 
Combining Angular and React Together
Combining Angular and React TogetherCombining Angular and React Together
Combining Angular and React Together
Sebastian Pederiva
 
A full introductory guide to React
A full introductory guide to ReactA full introductory guide to React
A full introductory guide to React
Jean Carlo Emer
 
Manage the Flux of your Web Application: Let's Redux
Manage the Flux of your Web Application: Let's ReduxManage the Flux of your Web Application: Let's Redux
Manage the Flux of your Web Application: Let's Redux
Commit University
 
React redux
React reduxReact redux
React redux
Michel Perez
 
Materi Modern React Redux Power Point.pdf
Materi Modern React Redux Power Point.pdfMateri Modern React Redux Power Point.pdf
Materi Modern React Redux Power Point.pdf
exiabreak
 
React outbox
React outboxReact outbox
React outbox
Angela Lehru
 
The Exciting Future Of React
The Exciting Future Of ReactThe Exciting Future Of React
The Exciting Future Of React
kristijanmkd
 
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
JSFestUA
 
React state managmenet with Redux
React state managmenet with ReduxReact state managmenet with Redux
React state managmenet with Redux
Vedran Blaženka
 
React 16: new features and beyond
React 16: new features and beyondReact 16: new features and beyond
React 16: new features and beyond
Artjoker
 
ReactJS.ppt
ReactJS.pptReactJS.ppt
ReactJS.ppt
MOMEKEMKUEFOUETDUREL
 
The evolution of redux action creators
The evolution of redux action creatorsThe evolution of redux action creators
The evolution of redux action creators
George Bukhanov
 
Stay with React.js in 2020
Stay with React.js in 2020Stay with React.js in 2020
Stay with React.js in 2020
Jerry Liao
 
react-slidlkjfl;kj;dlkjopidfjhopijgpoerjpofjiwoepifjopweifjepoies.pptx
react-slidlkjfl;kj;dlkjopidfjhopijgpoerjpofjiwoepifjopweifjepoies.pptxreact-slidlkjfl;kj;dlkjopidfjhopijgpoerjpofjiwoepifjopweifjepoies.pptx
react-slidlkjfl;kj;dlkjopidfjhopijgpoerjpofjiwoepifjopweifjepoies.pptx
PrathamSharma77833
 
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
Luciano Mammino
 
Workshop 19: ReactJS Introduction
Workshop 19: ReactJS IntroductionWorkshop 19: ReactJS Introduction
Workshop 19: ReactJS Introduction
Visual Engineering
 
Reactивная тяга
Reactивная тягаReactивная тяга
Reactивная тяга
Vitebsk Miniq
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners
Varun Raj
 
React & Redux for noobs
React & Redux for noobsReact & Redux for noobs
React & Redux for noobs
[T]echdencias
 
Combining Angular and React Together
Combining Angular and React TogetherCombining Angular and React Together
Combining Angular and React Together
Sebastian Pederiva
 
A full introductory guide to React
A full introductory guide to ReactA full introductory guide to React
A full introductory guide to React
Jean Carlo Emer
 
Manage the Flux of your Web Application: Let's Redux
Manage the Flux of your Web Application: Let's ReduxManage the Flux of your Web Application: Let's Redux
Manage the Flux of your Web Application: Let's Redux
Commit University
 
Materi Modern React Redux Power Point.pdf
Materi Modern React Redux Power Point.pdfMateri Modern React Redux Power Point.pdf
Materi Modern React Redux Power Point.pdf
exiabreak
 
The Exciting Future Of React
The Exciting Future Of ReactThe Exciting Future Of React
The Exciting Future Of React
kristijanmkd
 
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
JSFestUA
 
React state managmenet with Redux
React state managmenet with ReduxReact state managmenet with Redux
React state managmenet with Redux
Vedran Blaženka
 
React 16: new features and beyond
React 16: new features and beyondReact 16: new features and beyond
React 16: new features and beyond
Artjoker
 
The evolution of redux action creators
The evolution of redux action creatorsThe evolution of redux action creators
The evolution of redux action creators
George Bukhanov
 
Stay with React.js in 2020
Stay with React.js in 2020Stay with React.js in 2020
Stay with React.js in 2020
Jerry Liao
 
react-slidlkjfl;kj;dlkjopidfjhopijgpoerjpofjiwoepifjopweifjepoies.pptx
react-slidlkjfl;kj;dlkjopidfjhopijgpoerjpofjiwoepifjopweifjepoies.pptxreact-slidlkjfl;kj;dlkjopidfjhopijgpoerjpofjiwoepifjopweifjepoies.pptx
react-slidlkjfl;kj;dlkjopidfjhopijgpoerjpofjiwoepifjopweifjepoies.pptx
PrathamSharma77833
 
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
Luciano Mammino
 
Workshop 19: ReactJS Introduction
Workshop 19: ReactJS IntroductionWorkshop 19: ReactJS Introduction
Workshop 19: ReactJS Introduction
Visual Engineering
 
Ad

Recently uploaded (20)

Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025
kashifyounis067
 
Download Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With LatestDownload Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With Latest
tahirabibi60507
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025
kashifyounis067
 
Download Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With LatestDownload Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With Latest
tahirabibi60507
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 

React/Redux

  • 2. ECMAScript 6 (ES6) / ECMAScript 2015 (ES2015) const addition = (arg1, arg2) => arg1 + arg2; OR const addition = (arg1, arg2) => { return arg1 + arg2; }
  • 3. More ….  Block scope – (let and const)  Destructuring - let [a, b] = [10, 20];  Template String let fullName = `${firstName} ${lastName}`  Arrow function let square = x => x * x;
  • 4. What is React.js  A java script library for building user interface. Render UI and responds to events.  Declarative view for more predictable and easy to debug code.  Component based for reusability.  Building Components not templates  Semantically, it is nothing but HTML and java script.  Compare to other framework, it has full expressive power of java script.
  • 5. Separation of Concerns  Reduce coupling and increase cohesion.  In Traditional MVC pattern, Controller, ModelView and View are coupled, when you change one, you might need to change other.
  • 6. Traditional Performance Best Practices  Avoid expensive Document Object Model (DOM) operation  Minimize access to the DOM  Update elements offline before reinserting into the DOM  Avoid tweaking HTML layouts in Java script
  • 7. React Re-render  React is using Virtual DOM to re-render every thing on every update.  Not expensive, How?  Create lightweight description of UI component.  Diff it with the old one.  Compute minimal set of changes to apply to the DOM.  Batch execute all updates  Benefit  Clean  Fast
  • 8. How React Works It is fast because it compute minimal DOM operation and batch read and write. App State/ event React Component (UI) Virtual DOM Compute DOM operations Browser
  • 10. Java script Extension (JSX)  Initialization  const element = <h1>Hello, world!</h1>;  Embedding Expression  const element = ( <h1> Hello, {formatName(user)}! </h1> );  const element = <img src={user.avatarUrl}></img>;  Child Node  const element = (<div> <h1>Hello!</h1> <h2>Good to see you here.</h2> </div> );  (Tip) Must use capitalized variable for Type at Runtime function Story(props) { const SpecificStory = components[props.storyType]; return <SpecificStory story={props.story} />; }
  • 11. Props vs State  Both props and state are plain JS objects  Both props and state changes trigger a render update  Both props and state are deterministic  Props are a component configuration and it’s options, but state starts with default value when component mounts.  Props are immutable but state suffer from mutation in time (from user events)  Component always receive Props but manage their own state.
  • 12. Stateful component  Do not modify state directly  // Wrong this.state.comment = 'Hello';  // Correct  this.setState({comment: 'Hello'});  State updates may be asynchronous, so use prevState  // Wrong this.setState({ counter: this.state.counter + this.props.increment, });  // Correct this.setState((prevState, props) => ({ counter: prevState.counter + props.increment }));  State updates are merged into default state. fetchPosts().then(response => { this.setState({ posts: response.posts }); }); fetchComments().then(response => { this.setState({ comments: response.comments });  The data flows down (parent component -> child component), so state can be pass to child component as props
  • 13. Containment/Nested Component function FancyBorder(props) { return ( <div className={'FancyBorder FancyBorder-' + props.color}> {props.children} </div> ); } function WelcomeDialog() { return ( <FancyBorder color="blue"> <h1 className="Dialog-title"> Welcome </h1> <p className="Dialog-message"> Thank you for visiting our spacecraft! </p> </FancyBorder> ); } Here anything inside the <FancyBorder> JSX tag (h1 and p) gets passed into the FancyBorder component as a children prop. Since FancyBorder renders {props.children} inside a <div>, the passed elements appear in the final output.
  • 14. If/Else const Grade = ({marks} => { let level; if(marks > 90) { level = (<span>A</span>); } else { level = (<span>B</span>); } return (<div>{level}</div>); }) <Grade marks={94}/>
  • 15. Loop const CountryNames = ({countries} => { return (<ul> {countries.map((country) => { return <li>{country.name}</li>; })} </ul>); }) const countries = [{name: ‘USA’, name: ‘India’}] ; <CountryNames countries={countries} />
  • 16. Thinking In React  Start with UI Mock and Break up UI into a Component Hierarchy, Try out single responsibility principle, that is, a component should ideally only do one thing. If it ends up growing, it should be decomposed into smaller subcomponents.  Build a static (Dump) version in React  Identify The Minimal (but complete) Representation Of UI State,
  • 17. Rules  All React components must act like pure functions with respect to their props.  User-Defined Components Must Be Capitalized  React Must Be in Scope (Import before using)  Consider DRY: Don't Repeat Yourself.
  • 18. What is Redux?  Redux is a predictable state container for JavaScript apps  Or Redux allows you to manage the state with a minimal API but completely predictable behavior.  Basic Idea  (prevState, action) => newState
  • 19. Three Principles of Redux  Single source of truth - The state of your whole application is stored in an object tree within a single store.  State is read-only - The only way to change the state is to emit an action, an object describing what happened.  Changes are made with pure functions - To specify how the state tree is transformed by actions, you write pure reducers.
  • 21. Actions/Action Creator  Actions are payloads of information that send data from your application to your store. const ADD_TODO = 'ADD_TODO'  Action creators are exactly that—functions that create actions. function addTodo(text) { return { type: ADD_TODO, text } }
  • 22. Reducers  Reducers specify how the application’s state changes in response with some action happend.  (previousState, action) => newState  Reducer functions are called by the “Container” containers when there is a user action  If the reducer changes the state, Redux passes the new state to each component and React re-renders each component
  • 23. Store The Store is the object that brings actions and reducers together. The store has the following responsibilities:  Holds application state;  Allows access to state via getState();  Allows state to be updated via dispatch(action);  Registers listeners via subscribe(listener);  Handles unregistering of listeners via the function returned by subscribe(listener).
  • 24. How to use Redux  List State and Actions for each React Component  Create Action Creators for each action  Write Reducers for each Action  Create Container Component for selected Component  And defined Store to hold application state and attached all togather.
  • 26. Installation  npm install -g create-react-app  create-react-app hello-world  cd hello-world  npm start

Editor's Notes

  • #3: https://ponyfoo.com/articles/es6 https://github.deere.com/deere-ui/web-standards
  • #6: Coupling – The degree to which each program module relies on each of the other modules. Cohesion – The degree to which each element of modules belong together.
  • #14: JSX children passing as props
  • #26: Chrome plugin