SlideShare a Scribd company logo
Intro to React & Redux
Boris Dinkevich
http://500Tech.com
boris@500tech.com
Remember this day
Boris Dinkevich
- 4 years Dev Ops
- 4 years Embedded C
- 4 years Ruby on Rails
- 4 years JavaScript (Angular/React)
Developing stuff
Boris Dinkevich
- AngularJS Israel (4K ppl)
- ReactJS Israel (2K ppl)
- Angular UP
- React Next
- React Courses
- Figuring what tech ppl do in NYC??
These days
Introduction to ReactJS and Redux
ES2015 (ES6)
Const & Let
Strings
Arrow functions
Destructuring
A WORD ON TOOLS
npm - package repository
babel - transpiler
webpack - build tool
yarn - package repository
babel - transpiler
webpack - build tool
Create React App
https://github.com/facebookincubator/create-react-app
BACK TO REACT
HISTORY
Component Driven Development
COMPONENTS
Introduction to ReactJS and Redux
Introduction to ReactJS and Redux
Introduction to ReactJS and Redux
Introduction to ReactJS and Redux
Thinking in components
Thinking in components
COMPONENT INNARDS
Whats inside?
Component
Props
State
Main
Props
State
Footer
State
Header
State
Lifecycle methods
Mount
componentWillMount → Angular PreLink
componentDidMount → Angular PostLink
Update
componentWillUpdate
componentDidUpdate
Unmount
componentWillUnmount → $scope.$on('destroy')
Virtual DOM
Recipe
Ingredients
Eggs
Virtual DOM
Recipe
Ingredients
Eggs
Virtual DOM
Recipe
Ingredients
Eggs
Real DOM
=
Recipe
Ingredients
Eggs
Recipe
Ingredients
Eggs
Virtual DOM
Real DOM
Recipe
Ingredients
Eggs
Recipe
Ingredients
MilkEggs
New Virtual DOM
Recipe
Ingredients
Eggs
Old Virtual DOM
Real DOM
!=
Recipe
Ingredients
Eggs
Recipe
Ingredients
MilkEggs
New Virtual DOM
Recipe
Ingredients
Eggs
Old Virtual DOM
Real DOM
Milk
JSX
https://babeljs.io/repl/
Play with JSX online
=
function App() {

return React.createElement('div', null, [

React.createElement('h1', null, 'I am a component!'),

React.createElement('h2', null, 'I am a sub title')

]);

}


const App() = (

<div>

<h1>I am a component!</h1>

<h2>I am a sub title</h2>

</div>

);

PROPS
Component
Props
State
Passing Props
const Add = (props) => (

<h2>Its: { props.a + props.b }</h2>

);



const App = () => (

<Add a={ 2 } b={ 3 } />

);
Repeating with JavaScript
(3/3)
const Recipes = ({ recipes }) => (

<div>

<h1>Recipes</h1>

<ul>

{

recipes.map((recipe) => <Recipe recipe={ recipe } />)

}

</ul>

</div>

);
CLASSES
Make <App /> into a class
class App extends React.Component {

render() {

return (

<div>

<Recipes recipes={ recipes }/>

</div>

);

}

}

Component Lifecycle
class MyComponent extends React.Component {

constructor() { }

render() { }


getInitialState() { }

getDefaultProps() { }

componentWillMount() { }

componentDidMount() { }

componentWillReceiveProps() { }

shouldComponentUpdate() { }

componentWillUpdate() { }

componentDidUpdate() { }

componentWillUnmount() { }

}
https://facebook.github.io/react/docs/component-specs.html
FLUX
MVC
FLUX
Introduction to ReactJS and Redux
Chat
Notifications
Messages
Page Title
Chat
Notifications
Messages
Page Title
Data
Flux
Components
Dispatcher
ActionsStores
Game engine
Store
Recipes
Waffles
App
Add RecipeRecipes
Recipe…Omelette Pancakes Recipe… Recipe…
REDUX
Click
Timeout
AJAX
Websocket
EVERYTHING IS AN ACTION
Add Recipe
Toggle Favorite
Fetch Recipes
Start Network
Current State
Next State
Reducers
(processors)
Action
Many reducers can be chained
Must return a new state — never modify previous one
Object.assign or Immutable
Only one store
REDUCERS
CONNECT
State to React
Store
Recipes
Recipe 1 Recipe 2
App
Recipes Add Recipe
Recipe 1 Recipe 2
State to React
Store
Recipes
Recipe 1 Recipe 2
App
Recipes Add Recipe
Recipe 1 Recipe 2
State to React
Store
Recipes
Recipe 1 Recipe 2
App
Recipes Add Recipe
Recipe 1 Recipe 2
OUR STATE
State
Recipes
Omelette Pancaek
User
Boris
T1
The reducer
action = {

type: 'RENAME_RECIPE',

recipeId: 871,

name: 'Pancake'

};
const reducer = (state, action) => {

switch (action.type) {

case ‘RENAME_RECIPE':

const { recipeId, newName } = action;

state.recipes[recipeId].name = newName;

return state;

}

return state;

};
The reducer
action = {

type: 'RENAME_RECIPE',

recipeId: 871,

name: 'Pancake'

};
const reducer = (state, action) => {

switch (action.type) {

case ‘RENAME_RECIPE':

const { recipeId, newName } = action;

state.recipes[recipeId].name = newName;

return state;

}

return state;

};
The reducer
const reducer = (state, action) => {

switch (action.type) {

case ‘RENAME_RECIPE':

const recipe = state.recipes[action.recipeId];



const newRecipe = Object.assign({}, recipe, {

name: action.newName

});



const newRecipes = Object.assign({}, state.recipes, {

[action.recipeId]: newRecipe

});



return Object.assign({}, state, {

recipes: newRecipes

});

}

return state;

};



Object.assign()
const original = {

name: 'Cat',

age: 3

};



const updated = Object.assign({}, original, {

name: 'Dog'

});
updated

> { name: 'Dog', age: 3 }



updated === original

> false
REFERENCE TREES
State
Recipes
Omelette Pancaek
User
Boris
T1
Pancake
T2
REFERENCE TREES
State
Recipes
Omelette Pancaek
User
Boris
T1
Recipes
Omelette Pancake
T2
REFERENCE TREES
State
Recipes
Omelette Pancaek
User
Boris
T1
State
Recipes
Omelette Pancake
User
Boris
T2
IN MEMORY
State
Recipes
Omelette Pancaek
User
Boris
State
Recipes
Pancake
T1 T2
ACTION #2
State
Recipes
Omelette Pancaek
User
Boris
State
Recipes
Omelett Pancake
User
Boris
T1 T2
State
Recipes
Bacon Pancake
User
Boris
T3
IN MEMORY
State
Recipes
Omelette Pancaek
User
Boris
State
Recipes
Pancake
State
Recipes
Bacon
T1 T2 T3
Why not direct?
state.recipes[recipeId].name = newName;
OH, NO!
State
Recipes
Omelette Pancaek
User
Boris
State
Recipes
Pancake
State
Recipes
Bacon
T1 T2 T3
Omelett
User
Boris
User
Cat Pancake
OUT SIDE CHANGE
State
Recipes
Omelette Pancaek
User
Cat
State
Recipes
Pancake
State
Recipes
Bacon
T1 T2 T3
OH, NO!
State
Recipes
Omelette Pancaek
User
Cat
State
Recipes
Pancake
State
Recipes
Bacon
T1 T2 T3
Omelett
User
Cat
User
Cat Pancake
Console work
s1 = store.getState()
- Do an action
s2 = store.getState()
- Do an action
s3 = store.getState()
store.dispatch({ type: ‘SET_STATE’, payload: s1 });
Console work
s1 = store.getState()
- Do an action
s2 = store.getState()
- Do an action
s3 = store.getState()
store.dispatch({ type: ‘SET_STATE’, payload: s1 });
Console work
s1 = store.getState()
- Do an action
s2 = store.getState()
- Do an action
s3 = store.getState()
store.dispatch({ type: ‘SET_STATE’, payload: s1 });
Console work
s1 = store.getState()
- Do an action
s2 = store.getState()
- Do an action
s3 = store.getState()
store.dispatch({ type: ‘SET_STATE’, payload: s1 });
UNDO / REDO
BUT…
1. Actions like LOGIN
2. Actions from Middleware / Redux-Thunk
3. Layout / UI
Directory structure
reducers
store
components
ROUTING
React Router
import { Router, Route, browserHistory } from 'react-router'



render(

<Provider store={ store }>

<Router history={ browserHistory }>

..routes..


</Router>

</Provider>,

document.getElementById('app')

);
React Router


<Route path="" components={ App }>

<Route path="/add" component={ AddRecipe } />

<Route path="/recipe" component={ Recipes } />

</Route>

<Route path="*" component={ NotFound } />

REACT NATIVE
const HelloWeb = ({ name }) => (
<div>
<p>
Hello { name }
</p>
</div>
);
const HelloNative = ({ name }) => (
<View>
<Text>
Hello { name }
</Text>
</View>
);
One code
iOS
Android
Web
* MacOS
* Windows
* More?
Auto updates
No Apple Store / Google Play resubmit
Think of the bug solving!
SERVER RENDERING
Fetch
index.html
Parse & Show
Fetch JS
App & React
Load JS
Run React
AJAX
Update UI
Fetch
index.html
Parse & Show
time
Fetch
index.html
Parse & Show
Fetch JS
App & React
Load JS
Run React
AJAX
Update UI
Fetch
index.html
Parse & Show
Fetch JS
App & React
Load JS
Run React
Update UI Clickable
time
Load App
Local AJAX
Render to HTML
& JSON
Cachable
TESTS
Testing
Jest - Test framework - https://facebook.github.io/jest/
Enzyme - Test utils for React - https://github.com/airbnb/enzyme
Redux tests - http://redux.js.org/docs/recipes/WritingTests.html
SUMMARY
THE COMPLETE
REDUX BOOK
Read our blog:
http://blog.500tech.com
React & Redux

More Related Content

What's hot (20)

Evan Schultz - Angular Summit - 2016
Evan Schultz - Angular Summit - 2016
Evan Schultz
 
Switch to React.js from AngularJS developer
Switch to React.js from AngularJS developer
Eugene Zharkov
 
Integrating React.js with PHP projects
Integrating React.js with PHP projects
Ignacio Martín
 
Designing applications with Redux
Designing applications with Redux
Fernando Daciuk
 
Reactive.architecture.with.Angular
Reactive.architecture.with.Angular
Evan Schultz
 
Redux training
Redux training
dasersoft
 
Introduction to Redux
Introduction to Redux
Ignacio Martín
 
Getting started with ReactJS
Getting started with ReactJS
Krishna Sunuwar
 
Redux vs Alt
Redux vs Alt
Uldis Sturms
 
React on es6+
React on es6+
Nikolaus Graf
 
State Models for React with Redux
State Models for React with Redux
Stephan Schmidt
 
Let's discover React and Redux with TypeScript
Let's discover React and Redux with TypeScript
Mathieu Savy
 
Better React state management with Redux
Better React state management with Redux
Maurice De Beijer [MVP]
 
React with Redux
React with Redux
Stanimir Todorov
 
React & Redux
React & Redux
Federico Bond
 
React redux
React redux
Michel Perez
 
ProvJS: Six Months of ReactJS and Redux
ProvJS: Six Months of ReactJS and Redux
Thom Nichols
 
React state managmenet with Redux
React state managmenet with Redux
Vedran Blaženka
 
Introduction to react and redux
Introduction to react and redux
Cuong Ho
 
Angular2 & ngrx/store: Game of States
Angular2 & ngrx/store: Game of States
Oren Farhi
 
Evan Schultz - Angular Summit - 2016
Evan Schultz - Angular Summit - 2016
Evan Schultz
 
Switch to React.js from AngularJS developer
Switch to React.js from AngularJS developer
Eugene Zharkov
 
Integrating React.js with PHP projects
Integrating React.js with PHP projects
Ignacio Martín
 
Designing applications with Redux
Designing applications with Redux
Fernando Daciuk
 
Reactive.architecture.with.Angular
Reactive.architecture.with.Angular
Evan Schultz
 
Redux training
Redux training
dasersoft
 
Getting started with ReactJS
Getting started with ReactJS
Krishna Sunuwar
 
State Models for React with Redux
State Models for React with Redux
Stephan Schmidt
 
Let's discover React and Redux with TypeScript
Let's discover React and Redux with TypeScript
Mathieu Savy
 
Better React state management with Redux
Better React state management with Redux
Maurice De Beijer [MVP]
 
ProvJS: Six Months of ReactJS and Redux
ProvJS: Six Months of ReactJS and Redux
Thom Nichols
 
React state managmenet with Redux
React state managmenet with Redux
Vedran Blaženka
 
Introduction to react and redux
Introduction to react and redux
Cuong Ho
 
Angular2 & ngrx/store: Game of States
Angular2 & ngrx/store: Game of States
Oren Farhi
 

Similar to Introduction to ReactJS and Redux (20)

Understanding redux
Understanding redux
David Atchley
 
React and redux
React and redux
Mystic Coders, LLC
 
React js programming concept
React js programming concept
Tariqul islam
 
Materi Modern React Redux Power Point.pdf
Materi Modern React Redux Power Point.pdf
exiabreak
 
Redux js
Redux js
Nils Petersohn
 
Maintaining sanity in a large redux app
Maintaining sanity in a large redux app
Nitish Kumar
 
The Road To Redux
The Road To Redux
Jeffrey Sanchez
 
Redux essentials
Redux essentials
Chandan Kumar Rana
 
Redux Deep Dive - ReactFoo Pune 2018
Redux Deep Dive - ReactFoo Pune 2018
Aziz Khambati
 
React/Redux
React/Redux
Durgesh Vaishnav
 
Getting started with React and Redux
Getting started with React and Redux
Paddy Lock
 
An Overview of the React Ecosystem
An Overview of the React Ecosystem
FITC
 
#FrontConf2017 — Enhance your User (and Developer) Experience with React & Redux
#FrontConf2017 — Enhance your User (and Developer) Experience with React & Redux
phacks
 
Strategies for Mitigating Complexity in React Based Redux Applicaitons
Strategies for Mitigating Complexity in React Based Redux Applicaitons
garbles
 
An Intense Overview of the React Ecosystem
An Intense Overview of the React Ecosystem
Rami Sayar
 
Workshop 19: ReactJS Introduction
Workshop 19: ReactJS Introduction
Visual Engineering
 
ReactJS
ReactJS
Kamlesh Singh
 
Redux
Redux
Anurag Chitti
 
An Introduction to React -- FED Date -- IBM Design
An Introduction to React -- FED Date -- IBM Design
Josh Black
 
Reactивная тяга
Reactивная тяга
Vitebsk Miniq
 
React js programming concept
React js programming concept
Tariqul islam
 
Materi Modern React Redux Power Point.pdf
Materi Modern React Redux Power Point.pdf
exiabreak
 
Maintaining sanity in a large redux app
Maintaining sanity in a large redux app
Nitish Kumar
 
Redux Deep Dive - ReactFoo Pune 2018
Redux Deep Dive - ReactFoo Pune 2018
Aziz Khambati
 
Getting started with React and Redux
Getting started with React and Redux
Paddy Lock
 
An Overview of the React Ecosystem
An Overview of the React Ecosystem
FITC
 
#FrontConf2017 — Enhance your User (and Developer) Experience with React & Redux
#FrontConf2017 — Enhance your User (and Developer) Experience with React & Redux
phacks
 
Strategies for Mitigating Complexity in React Based Redux Applicaitons
Strategies for Mitigating Complexity in React Based Redux Applicaitons
garbles
 
An Intense Overview of the React Ecosystem
An Intense Overview of the React Ecosystem
Rami Sayar
 
Workshop 19: ReactJS Introduction
Workshop 19: ReactJS Introduction
Visual Engineering
 
An Introduction to React -- FED Date -- IBM Design
An Introduction to React -- FED Date -- IBM Design
Josh Black
 
Reactивная тяга
Reactивная тяга
Vitebsk Miniq
 
Ad

Recently uploaded (20)

SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
Transmission Media. (Computer Networks)
Transmission Media. (Computer Networks)
S Pranav (Deepu)
 
How the US Navy Approaches DevSecOps with Raise 2.0
How the US Navy Approaches DevSecOps with Raise 2.0
Anchore
 
Software Testing & it’s types (DevOps)
Software Testing & it’s types (DevOps)
S Pranav (Deepu)
 
Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3
Gaurav Sharma
 
Artificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across Industries
SandeepKS52
 
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
joybepari360
 
Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
BradBedford3
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
wAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptx
SimonedeGijt
 
Step by step guide to install Flutter and Dart
Step by step guide to install Flutter and Dart
S Pranav (Deepu)
 
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
BradBedford3
 
FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025
Safe Software
 
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Natan Silnitsky
 
IBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - Introduction
Gaurav Sharma
 
How to Choose the Right Web Development Agency.pdf
How to Choose the Right Web Development Agency.pdf
Creative Fosters
 
Migrating to Azure Cosmos DB the Right Way
Migrating to Azure Cosmos DB the Right Way
Alexander (Alex) Komyagin
 
What is data visualization and how data visualization tool can help.pdf
What is data visualization and how data visualization tool can help.pdf
Varsha Nayak
 
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Varsha Nayak
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
Transmission Media. (Computer Networks)
Transmission Media. (Computer Networks)
S Pranav (Deepu)
 
How the US Navy Approaches DevSecOps with Raise 2.0
How the US Navy Approaches DevSecOps with Raise 2.0
Anchore
 
Software Testing & it’s types (DevOps)
Software Testing & it’s types (DevOps)
S Pranav (Deepu)
 
Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3
Gaurav Sharma
 
Artificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across Industries
SandeepKS52
 
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
joybepari360
 
Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
BradBedford3
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
wAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptx
SimonedeGijt
 
Step by step guide to install Flutter and Dart
Step by step guide to install Flutter and Dart
S Pranav (Deepu)
 
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
BradBedford3
 
FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025
Safe Software
 
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Natan Silnitsky
 
IBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - Introduction
Gaurav Sharma
 
How to Choose the Right Web Development Agency.pdf
How to Choose the Right Web Development Agency.pdf
Creative Fosters
 
What is data visualization and how data visualization tool can help.pdf
What is data visualization and how data visualization tool can help.pdf
Varsha Nayak
 
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Varsha Nayak
 
Ad

Introduction to ReactJS and Redux