SlideShare ist ein Scribd-Unternehmen logo
1 von 72
Downloaden Sie, um offline zu lesen
BUILDING MODERN WEB
APPLICATIONS USING
REACT & REDUX
Maxime Najim
Thursday, May 18,
2018
WoW Tech Meetup
About Me
• Software architect and a full stack web
developer
• Over 12 years experience building
large, highly scalable and reliable web
applications for companies like
Yahoo!, Apple, Netflix, and Walmart
• Co-author of the O'Reilly Media book
entitled "Building Isomorphic
JavaScript Apps” and an upcoming
video series: “Universal JavaScript
with React, Node, and Redux”.
Publications
Sr. Software Architect

Walmart Global eCommerce
September 2016
August 2017
Building Modern Web
Applications using
React & Redux
Building Modern Web
Applications using
React & Redux
https://www.uber.com/ https://mobile.twitter.com
Modern Web Applications
Modern Web Applications
Unified View of the Current State
Cart State
Filter State
Button State
Action - Add to Cart
Action - Add to Cart
Action - Add to Cart
State 1 State 2 State 3 State N
Action 1 Action 2 Action N
Action - Add to Cart
Old State New State
Action
The Problem of Modern Web Applications
As an application grows it becomes harder to determine the overall state of the
application and cumbersome to understand where updates are coming from.
The Anatomy of a Client Application
Data View
Web App
Events
• Data: Server Data and Input
• Display: A visual representation of the
data
• Event Handlers: User interactions
The Anatomy of a Client Application
Redux View
Web App
Events
• Data: Server Data and Input
• Display: A visual representation of the
data
• Event Handlers: User interactions
The Anatomy of a Client Application
Redux React
Web App
Events
• Data: Server Data and Input
• Display: A visual representation of the
data
• Event Handlers: User interactions
Building Modern Web
Applications using
React & Redux
Redux - 

Basic Flow
• Uni-directional data flow
• Immutable single store
• Action object describing
what happened.
• All state updates are
performed by pure
functions
ref: http://slides.com/jenyaterpil/redux-from-twitter-hype-to-production#/9
(state, action) => state
Redux - 

Basic Flow
• An action is dispatched
(often in response to user
interaction).
• The root reducer function is
called with the current state
and the dispatched action.
• It then returns the new
state.
• React app retrieves the
updated state and re-renders
(state, action) => state
Action
Event
Redux - 

Basic Flow
• An action is dispatched
(often in response to user
interaction).
• The root reducer function is
called with the current state
and the dispatched action.
• It then returns the new
state.
• React app retrieves the
updated state and re-renders
(state, action) => state
State
Action
Redux - 

Basic Flow
• An action is dispatched
(often in response to user
interaction).
• The root reducer function is
called with the current state
and the dispatched action.
• It then returns the new
state.
• View retrieves the updated
state and re-renders
(state, action) => state
State
Redux - 

Actions
Redux - 

Reducer
Redux - 

Store
Local unified copy of distributed data
Redux - 

Async Flow
• Action creator can
have logic for
communicating with
backend APIs
• Middleware provides
third-party extension
point that can be
added to redux
Redux Side Effects
Async Action Creator - API Call
actions.js
Redux - 

Async Flow
• An event in the UI
causes and action
created to be invoked
Redux - 

Async Flow
• An event in the UI
causes and action
created to be invoked
• A function is returned
by the action creator
Redux - 

Async Flow
• An event in the UI
causes and action
created to be invoked
• A function is returned
by the action creator
• Middleware calls the
function
Redux - 

Async Flow
• Dispatches a “Request
Started” action and
calls the API.
Redux - 

Async Flow
• Dispatches a “Request
Started” action and
calls the API.
• Once a response is
returned from the API
call.
Redux - 

Async Flow
• Dispatch a “Request
Started” action and
call the API
• A response is returned
from the API call
• Dispatch a “Request
Succeeded” action
Redux - 

Async Flow
• Dispatch a “Request
Started” action and
call the API
• A response is returned
from the API call
• Dispatch a “Request
Succeeded” action
Building Modern Web
Applications using
React & Redux
Redux - 

Async Flow
• Dispatch a “Request
Started” action and
call the API
• A response is returned
from the API call
• Dispatch a “Request
Succeeded” action
Redux - 

Async Flow
• Dispatch a “Request
Started” action and
call the API
• A response is returned
from the API call
• Dispatch a “Request
Succeeded” action
Web Browser
Rendering
Engine 



(HTML, CSS)
Scripting Engine
(JavaScript)
Browser
APIs
(Document,
Window,
Navigator)
HTML DOM createElement()
client/App.js
Web Browser
Rendering
Engine 



(HTML, CSS)
Scripting Engine
Browser
APIs
(Document,
Window,
Navigator)
React.js
Components
Data
Virtual DOM
minimal set of

real DOM 

mutations
React - Hello World
client/App.jsx
React - Hello World
client/App.jsx
React - Hello World
client/App.jsx
React - Hello World
client/index.jsx
React - Smart Greeting (JSX)
client/App.jsx
React - Clickable Image
client/ClickableImage.jsx
React - Clickable Image
client/App.jsx
React - Product Grid
client/App.jsx
React - Product Component
client/Product.jsx
React - Component Communication
App
Product
Product
Picture
Product
Descrip.
props
props props
React - Product Component
client/Product.jsx
Building Modern Web
Applications using
React & Redux
Redux - 

Basic Flow
• Uni-directional data flow
• Immutable single store
• Action object describing
what happened.
• All state updates are
performed by pure
functions
store.dispatch()
store.subscribe(…)
Container/Presentational Components
Presentational Components Container Components
Purpose How things look 

(markup, styles)
How things work 

(data fetching, state updates)
Aware of Redux No Yes
To read data Read data from props Subscribe to Redux state
To change data Invoke callbacks from props Dispatch Redux actions
ref: http://redux.js.org/docs/basics/UsageWithReact.html
Container/Presentational Components
index.jsx
Container/Presentational Components
./containers/CounterContainer.jsx
Container/Presentational Components
./components/Counter.jsx
Container/Presentational Components
./components/Counter.jsx
React-Redux: Connect
./containers/CounterContainer.jsx
React-Redux: Provider
index.jsx
Building Modern Web
Applications using
React & Redux
61
https://nodejs.org/en/download
Hello World with node.js
http://www.modulecounts.com/
$ node
> console.log('Hello World');
Hello World
Interactive Shell
Execute JavaScript file
$ echo "console.log('Hello World');" > hello.js
$ node hello.js
Hello World
npm - module count
http://www.modulecounts.com/
NPM is the fasts growing and most active public repository
Creating a package.json
{
"name": "my-app",
"version": "0.1.0",
"dependencies": {
…
},
"devDependencies": {
…
},
"scripts": {
…
}
}
package.json
Creating a package.json
package.json
{
"name": "my-app",
"version": "0.1.0",
"dependencies": {
"express": "^4.15.2",
"react": "^15.4.2",
"react-dom": “^15.4.2”,
"react-redux": "^5.0.2",
"react-router": "^3.0.2",
"redux": "^3.6.0",
"redux-thunk": "^2.2.0"
},
"devDependencies": {
…
},
"scripts": {
$ npm install react react-dom … —save
Run
Creating a package.json
package.json
{
"name": "my-app",
"version": "0.1.0",
"dependencies": {
…
},
"devDependencies": {
"babel-core": "^6.24.0",
"babel-loader": "^6.4.1",
"babel-preset-es2015": "^6.24.0",
"babel-preset-react": "^6.23.0",
"webpack": "^2.3.2"
},
"scripts": {
…
}
$ npm install babel-core babel-loader

.. webpack --save-dev
Run
Creating a package.json
{
"name": "my-app",
"version": "0.1.0",
"dependencies": {
…
},
"devDependencies": {
…
},
"scripts": {
"start": "node server/index.js”,
"build": "webpack --config webpack.config.js"
}
}
package.json
node_modules folder
App Directory
|-client
|-node_modules
|-package.json
|-server
|-webpack.config.js
node_modules folder
webpack.config.js
var config = {
entry:"/index.jsx",
output: {
filename: "bundle.js"
},
module: {
loaders: [{
test: /.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
include: “client”,
}]
}
};
User List/Card Example
Home Component User Component
URL: /user/1URL: /
DEMO
https://github.com/maximenajim/Universal-JavaScript-with-React-Node-and-Redux
Learn More…
Thank You
@softwarecrafts www.oreilly.com/pub/au/6521https://github.com/maximenajim

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

React.js+Redux Workshops
React.js+Redux WorkshopsReact.js+Redux Workshops
React.js+Redux Workshops
 
React JS: A Secret Preview
React JS: A Secret PreviewReact JS: A Secret Preview
React JS: A Secret Preview
 
React.js and Redux overview
React.js and Redux overviewReact.js and Redux overview
React.js and Redux overview
 
ReactJS presentation
ReactJS presentationReactJS presentation
ReactJS presentation
 
React / Redux Architectures
React / Redux ArchitecturesReact / Redux Architectures
React / Redux Architectures
 
React JS part 1
React JS part 1React JS part 1
React JS part 1
 
React & redux
React & reduxReact & redux
React & redux
 
React introduction
React introductionReact introduction
React introduction
 
React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥
 
Academy PRO: React JS. Redux & Tooling
Academy PRO: React JS. Redux & ToolingAcademy PRO: React JS. Redux & Tooling
Academy PRO: React JS. Redux & Tooling
 
Workshop React.js
Workshop React.jsWorkshop React.js
Workshop React.js
 
React, Flux and a little bit of Redux
React, Flux and a little bit of ReduxReact, Flux and a little bit of Redux
React, Flux and a little bit of Redux
 
React js
React jsReact js
React js
 
Getting Started with React-Nathan Smith
Getting Started with React-Nathan SmithGetting Started with React-Nathan Smith
Getting Started with React-Nathan Smith
 
Designing applications with Redux
Designing applications with ReduxDesigning applications with Redux
Designing applications with Redux
 
React.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOMReact.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOM
 
React js
React jsReact js
React js
 
20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native
 
Getting started with Redux js
Getting started with Redux jsGetting started with Redux js
Getting started with Redux js
 
React js
React jsReact js
React js
 

Ähnlich wie Building Modern Web Applications using React and Redux

Ähnlich wie Building Modern Web Applications using React and Redux (20)

Spfx with react redux
Spfx with react reduxSpfx with react redux
Spfx with react redux
 
Дмитрий Тежельников «Разработка вэб-решений с использованием Asp.NET.Core и ...
Дмитрий Тежельников  «Разработка вэб-решений с использованием Asp.NET.Core и ...Дмитрий Тежельников  «Разработка вэб-решений с использованием Asp.NET.Core и ...
Дмитрий Тежельников «Разработка вэб-решений с использованием Asp.NET.Core и ...
 
Introduction to React, Flux, and Isomorphic Apps
Introduction to React, Flux, and Isomorphic AppsIntroduction to React, Flux, and Isomorphic Apps
Introduction to React, Flux, and Isomorphic Apps
 
Asp dot net lifecycle in details
Asp dot net lifecycle in detailsAsp dot net lifecycle in details
Asp dot net lifecycle in details
 
Why ASP.NET Development is Important?
Why ASP.NET Development is Important?Why ASP.NET Development is Important?
Why ASP.NET Development is Important?
 
Understanding Facebook's React.js
Understanding Facebook's React.jsUnderstanding Facebook's React.js
Understanding Facebook's React.js
 
An Overview of the React Ecosystem
An Overview of the React EcosystemAn Overview of the React Ecosystem
An Overview of the React Ecosystem
 
Asp.net control
Asp.net controlAsp.net control
Asp.net control
 
Performance and Scalability Art of Isomorphic React Applications
Performance and Scalability Art of Isomorphic React ApplicationsPerformance and Scalability Art of Isomorphic React Applications
Performance and Scalability Art of Isomorphic React Applications
 
React && React Native workshop
React && React Native workshopReact && React Native workshop
React && React Native workshop
 
MidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
MidwestJS 2014 Reconciling ReactJS as a View Layer ReplacementMidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
MidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
 
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
 
Introduction to react and redux
Introduction to react and reduxIntroduction to react and redux
Introduction to react and redux
 
State Models for React with Redux
State Models for React with ReduxState Models for React with Redux
State Models for React with Redux
 
React + Flux = Joy
React + Flux = JoyReact + Flux = Joy
React + Flux = Joy
 
Damian Kmiecik - Road trip with Redux
Damian Kmiecik - Road trip with ReduxDamian Kmiecik - Road trip with Redux
Damian Kmiecik - Road trip with Redux
 
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
 
Asp.net life cycle in depth
Asp.net life cycle in depthAsp.net life cycle in depth
Asp.net life cycle in depth
 
Asp.net life cycle
Asp.net life cycleAsp.net life cycle
Asp.net life cycle
 
Redux Tech Talk
Redux Tech TalkRedux Tech Talk
Redux Tech Talk
 

Kürzlich hochgeladen

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
dharasingh5698
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 

Kürzlich hochgeladen (20)

Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 

Building Modern Web Applications using React and Redux