#FrontConf2017 — Enhance your User (and Developer) Experience with React & Redux

P
Enhance your User (and Developer)
Experience with React & Redux
& /phacks
Hi! I am Nicolas Goutay. I work at Theodo, a web
consultancy based in Paris & London. I build JS &
Python web applications. I like music, typography
and I have stage fright am excited to be here with all
of you. You can find me online (Twitter & GitHub) on
@phacks.
React & Redux
A Lego analogy
React would be a Lego instruction manual, where
bricks are DOM nodes. It takes care of how things
look for the end user.
test te
fort veau
jean jean
humain loup
travers des
gout bon
bonbon
cher non
How to build a F1
On modern Web apps, how things look are usually a
function of user interactions. In this analogy, the
user is Elya, my 5 year-old niece. Red is her favorite
color, so she wants the car to be red 🏎.
This is where 🤖 Redux kicks in.
# “I want the car to be red.”
🤖 “Dispatch the CHANGE_CAR_COLOR action with the
payload color: red”
$ “OK! I take note that you want your car red…”
🤖 “A reducer will process the action, and will add
color: red to the Redux store”
$ “…I sift through all the messy Legos to find red bricks…”
🤖 “The store passes the property color: red to
React components”
$ “…and I follow the instructions again with the red bricks”
test te
fort veau
jean jean
humain loup
travers des
gout bon
bonbon
cher non
How to build a F1
Redux store
color: red
# “I want the car number to by my age, not yours”
🤖 “Dispatch the CHANGE_CAR_NUMBER action with the
payload number: 5”
$ “Oh there we go again. 5 it is…”
🤖 “A reducer will process the action, and will add
number: 5 to the Redux store”
$ “…Where on Earth did I put this sticker…”
🤖 “The store passes the property number: 5 to
React components”
$ “…there you go! Now go find your parents 😅”
test te
fort veau
jean jean
humain loup
travers des
gout bon
bonbon
cher non
How to build a F1
Redux store
color: red
number: 5
Redux — Now with actual code
export function changeCarColor(color) {
return {
type: 'CHANGE_CAR_COLOR',
color
}
}
🤖 “Dispatch the CHANGE_CAR_COLOR action with the
payload color”
Redux — Now with actual code
function formulaOneApp(state = {}, action) {
switch (action.type) {
case 'CHANGE_CAR_COLOR':
return Object.assign({}, state, {
color: action.color
})
default:
return state
}
}
🤖 “A reducer will process the action, and will add
color to the Redux store”
Redux — Now with actual code
🤖 “The store passes the properties color and
number to React components”
import React from 'react'
const FormulaOne = ({ color, number }) => (
<div>
<CarBody color={color} />
<Decorations number={number} />
</div>
)
Developer Experience — Easier Debugging
Developer Experience — Easier Debugging
Developer Experience — Easier Debugging
This is what the Redux Store of my current project
look like. I can inspect every variable, which are
updated in real time.
User Experience — Built-in Performance
User Experience — Built-in Performance
React components are only repainted when their
props or inner state change.
React API methods like shouldComponentUpdate
allow us to have a finer-grained control about render
performance.
Developer Experience — “Reasonaboutability”
Developer Experience — “Reasonaboutability”
React developer Jani Eväkallio coined the term
“reasonaboutability” (easiness to reason about). I
love it, and it matches perfectly what I feel about
Redux. Here are the Three Principles of Redux:
Developer Experience — “Reasonaboutability”
React developer Jani Eväkallio coined the term
“reasonaboutability” (easiness to reason about). I
love it, and it matches perfectly what I feel about
Redux. Here are the Three Principles of Redux:
Single Source of Truth: all the data/UI state displayed on the
app come from the same JS object. Facilitates debugging.
Developer Experience — “Reasonaboutability”
React developer Jani Eväkallio coined the term
“reasonaboutability” (easiness to reason about). I
love it, and it matches perfectly what I feel about
Redux. Here are the Three Principles of Redux:
Single Source of Truth: all the data/UI state displayed on the
app come from the same JS object. Facilitates debugging.
State is read-only: The only way to change the state is to
emit an action, an object describing what happened.
Provides a single, robust & semantic way to deal with
interactions.
Developer Experience — “Reasonaboutability”
React developer Jani Eväkallio coined the term
“reasonaboutability” (easiness to reason about). I
love it, and it matches perfectly what I feel about
Redux. Here are the Three Principles of Redux:
Single Source of Truth: all the data/UI state displayed on the
app come from the same JS object. Facilitates debugging.
State is read-only: The only way to change the state is to
emit an action, an object describing what happened.
Provides a single, robust & semantic way to deal with
interactions.
Changes are made with pure functions: the Store can only
be updated with pure functions (reducers). Prevents nasty
side effects.
Redux comes with other benefits — and tradeoffs
🤩 Tests are blissfully easy to write: Reducers are pure
functions. Just test that given an input, they yield the right
output.
it('handles ADD_ITEM by adding the item', () => {
const initialState = fromJS({
todos: [
{id: 1, text: 'React', status: 'active'}
]
});
const action = {
type: 'ADD_ITEM',
text: 'Redux'
}
const nextState = reducer(initialState, action);
expect(nextState).to.equal(fromJS({
todos: [
{id: 1, text: 'React', status: 'active'},
{id: 2, text: 'Redux', status: 'active'},
]
}));
});
🛠 Rich ecosystem: Redux has an API to plug-in middlewares.
There are tons of them: for logging, offline capabilities,
async, forms, optimistic UIs…
Tip: 🔗 github.com/markerikson/react-redux-links is a
great place to start!
🤓 Code structure is key: Since all UI is derived from a single
JS object, it needs to be carefully designed and constantly
adjusted to business requirements.
Tip: Learn from the best! Twitter & Pinterest both use Redux,
and the structure is available for anybody to see with the
React Dev Tools!
Tip: I just got used to it. After a while it even feels more productive
than Angular 1, because you know exactly what to do to get
everything to work together.
😓 Verbosity: to write a feature, you would usually need to
write an action, a reducer, a selector, a saga… It feels quite
cumbersome compared to Angular 1.
Conclusion
React with Redux is a mature framework that
empowers developers to produce better apps in a
much better way.
Want to dive in?
I wrote a full-featured, test-driven tutorial on writing
a Todo List using React & Redux
🔗 http://github.com/phacks/redux-todomvc
Danke!
Slides are available at phacks.github.io
& /phacks
1 of 32

Recommended

How do i - create a native interface by
How do i -  create a native interfaceHow do i -  create a native interface
How do i - create a native interfaceShai Almog
154 views16 slides
jQuery Plugin by
jQuery PluginjQuery Plugin
jQuery Pluginrbiggs
417 views8 slides
React Native +Redux + ES6 (Updated) by
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)Chiew Carol
694 views31 slides
React Native Workshop - React Alicante by
React Native Workshop - React AlicanteReact Native Workshop - React Alicante
React Native Workshop - React AlicanteIgnacio Martín
1.7K views125 slides
Introduction to React Native Workshop by
Introduction to React Native WorkshopIntroduction to React Native Workshop
Introduction to React Native WorkshopIgnacio Martín
1.5K views126 slides
Mattia Manzati - Real-World MobX Project Architecture - Codemotion Rome 2019 by
Mattia Manzati - Real-World MobX Project Architecture - Codemotion Rome 2019Mattia Manzati - Real-World MobX Project Architecture - Codemotion Rome 2019
Mattia Manzati - Real-World MobX Project Architecture - Codemotion Rome 2019Codemotion
2.9K views150 slides

More Related Content

Similar to #FrontConf2017 — Enhance your User (and Developer) Experience with React & Redux

Connecting with the enterprise - The how and why of connecting to Enterprise ... by
Connecting with the enterprise - The how and why of connecting to Enterprise ...Connecting with the enterprise - The how and why of connecting to Enterprise ...
Connecting with the enterprise - The how and why of connecting to Enterprise ...Kevin Poorman
497 views20 slides
Rethinking Best Practices by
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practicesfloydophone
130.2K views78 slides
All a flutter about Flutter.io by
All a flutter about Flutter.ioAll a flutter about Flutter.io
All a flutter about Flutter.ioSteven Cooper
529 views63 slides
Mobile App Feature Configuration and A/B Experiments by
Mobile App Feature Configuration and A/B ExperimentsMobile App Feature Configuration and A/B Experiments
Mobile App Feature Configuration and A/B Experimentslacyrhoades
3.1K views74 slides
Huge web apps web expo 2013 by
Huge web apps web expo 2013Huge web apps web expo 2013
Huge web apps web expo 2013Daniel Steigerwald
2.1K views67 slides
High Performance web apps in Om, React and ClojureScript by
High Performance web apps in Om, React and ClojureScriptHigh Performance web apps in Om, React and ClojureScript
High Performance web apps in Om, React and ClojureScriptLeonardo Borges
11.9K views43 slides

Similar to #FrontConf2017 — Enhance your User (and Developer) Experience with React & Redux(20)

Connecting with the enterprise - The how and why of connecting to Enterprise ... by Kevin Poorman
Connecting with the enterprise - The how and why of connecting to Enterprise ...Connecting with the enterprise - The how and why of connecting to Enterprise ...
Connecting with the enterprise - The how and why of connecting to Enterprise ...
Kevin Poorman497 views
Rethinking Best Practices by floydophone
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practices
floydophone130.2K views
All a flutter about Flutter.io by Steven Cooper
All a flutter about Flutter.ioAll a flutter about Flutter.io
All a flutter about Flutter.io
Steven Cooper529 views
Mobile App Feature Configuration and A/B Experiments by lacyrhoades
Mobile App Feature Configuration and A/B ExperimentsMobile App Feature Configuration and A/B Experiments
Mobile App Feature Configuration and A/B Experiments
lacyrhoades3.1K views
High Performance web apps in Om, React and ClojureScript by Leonardo Borges
High Performance web apps in Om, React and ClojureScriptHigh Performance web apps in Om, React and ClojureScript
High Performance web apps in Om, React and ClojureScript
Leonardo Borges11.9K views
Rubyconf2016 - Solving communication problems in distributed teams with BDD by Rodrigo Urubatan
Rubyconf2016 - Solving communication problems in distributed teams with BDDRubyconf2016 - Solving communication problems in distributed teams with BDD
Rubyconf2016 - Solving communication problems in distributed teams with BDD
Rodrigo Urubatan406 views
The State of Front-end At CrowdTwist by Mark Fayngersh
The State of Front-end At CrowdTwistThe State of Front-end At CrowdTwist
The State of Front-end At CrowdTwist
Mark Fayngersh2.7K views
React && React Native workshop by Stacy Goh
React && React Native workshopReact && React Native workshop
React && React Native workshop
Stacy Goh611 views
Plugin for Plugin, или расширяем Android New Build System. Антон Руткевич by Yandex
 Plugin for Plugin, или расширяем Android New Build System. Антон Руткевич Plugin for Plugin, или расширяем Android New Build System. Антон Руткевич
Plugin for Plugin, или расширяем Android New Build System. Антон Руткевич
Yandex372 views
Connect.js - Exploring React.Native by joshcjensen
Connect.js - Exploring React.NativeConnect.js - Exploring React.Native
Connect.js - Exploring React.Native
joshcjensen786 views
N Things You Don't Want to Repeat in React Native by Anton Kulyk
N Things You Don't Want to Repeat in React NativeN Things You Don't Want to Repeat in React Native
N Things You Don't Want to Repeat in React Native
Anton Kulyk225 views
Let's discover React and Redux with TypeScript by Mathieu Savy
Let's discover React and Redux with TypeScriptLet's discover React and Redux with TypeScript
Let's discover React and Redux with TypeScript
Mathieu Savy729 views
Professional JavaScript: AntiPatterns by Mike Wilcox
Professional JavaScript: AntiPatternsProfessional JavaScript: AntiPatterns
Professional JavaScript: AntiPatterns
Mike Wilcox4K views
resolvendo problemas de comunicação em equipes distribuídas com bdd by Rodrigo Urubatan
resolvendo problemas de comunicação em equipes distribuídas com bddresolvendo problemas de comunicação em equipes distribuídas com bdd
resolvendo problemas de comunicação em equipes distribuídas com bdd
Rodrigo Urubatan761 views
Intro to React - Featuring Modern JavaScript by jasonsich
Intro to React - Featuring Modern JavaScriptIntro to React - Featuring Modern JavaScript
Intro to React - Featuring Modern JavaScript
jasonsich856 views
Adding a modern twist to legacy web applications by Jeff Durta
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
Jeff Durta354 views

Recently uploaded

DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J... by
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...Deltares
9 views24 slides
DSD-INT 2023 Dam break simulation in Derna (Libya) using HydroMT_SFINCS - Prida by
DSD-INT 2023 Dam break simulation in Derna (Libya) using HydroMT_SFINCS - PridaDSD-INT 2023 Dam break simulation in Derna (Libya) using HydroMT_SFINCS - Prida
DSD-INT 2023 Dam break simulation in Derna (Libya) using HydroMT_SFINCS - PridaDeltares
18 views9 slides
DevsRank by
DevsRankDevsRank
DevsRankdevsrank786
11 views1 slide
Unleash The Monkeys by
Unleash The MonkeysUnleash The Monkeys
Unleash The MonkeysJacob Duijzer
7 views28 slides
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI... by
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...Marc Müller
36 views83 slides
Software evolution understanding: Automatic extraction of software identifier... by
Software evolution understanding: Automatic extraction of software identifier...Software evolution understanding: Automatic extraction of software identifier...
Software evolution understanding: Automatic extraction of software identifier...Ra'Fat Al-Msie'deen
7 views33 slides

Recently uploaded(20)

DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J... by Deltares
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...
Deltares9 views
DSD-INT 2023 Dam break simulation in Derna (Libya) using HydroMT_SFINCS - Prida by Deltares
DSD-INT 2023 Dam break simulation in Derna (Libya) using HydroMT_SFINCS - PridaDSD-INT 2023 Dam break simulation in Derna (Libya) using HydroMT_SFINCS - Prida
DSD-INT 2023 Dam break simulation in Derna (Libya) using HydroMT_SFINCS - Prida
Deltares18 views
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI... by Marc Müller
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...
Marc Müller36 views
Software evolution understanding: Automatic extraction of software identifier... by Ra'Fat Al-Msie'deen
Software evolution understanding: Automatic extraction of software identifier...Software evolution understanding: Automatic extraction of software identifier...
Software evolution understanding: Automatic extraction of software identifier...
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge... by Deltares
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...
Deltares16 views
Fleet Management Software in India by Fleetable
Fleet Management Software in India Fleet Management Software in India
Fleet Management Software in India
Fleetable11 views
Copilot Prompting Toolkit_All Resources.pdf by Riccardo Zamana
Copilot Prompting Toolkit_All Resources.pdfCopilot Prompting Toolkit_All Resources.pdf
Copilot Prompting Toolkit_All Resources.pdf
Riccardo Zamana6 views
DSD-INT 2023 Thermobaricity in 3D DCSM-FM - taking pressure into account in t... by Deltares
DSD-INT 2023 Thermobaricity in 3D DCSM-FM - taking pressure into account in t...DSD-INT 2023 Thermobaricity in 3D DCSM-FM - taking pressure into account in t...
DSD-INT 2023 Thermobaricity in 3D DCSM-FM - taking pressure into account in t...
Deltares9 views
Upgrading Incident Management with Icinga - Icinga Camp Milan 2023 by Icinga
Upgrading Incident Management with Icinga - Icinga Camp Milan 2023Upgrading Incident Management with Icinga - Icinga Camp Milan 2023
Upgrading Incident Management with Icinga - Icinga Camp Milan 2023
Icinga38 views
Geospatial Synergy: Amplifying Efficiency with FME & Esri ft. Peak Guest Spea... by Safe Software
Geospatial Synergy: Amplifying Efficiency with FME & Esri ft. Peak Guest Spea...Geospatial Synergy: Amplifying Efficiency with FME & Esri ft. Peak Guest Spea...
Geospatial Synergy: Amplifying Efficiency with FME & Esri ft. Peak Guest Spea...
Safe Software412 views
DSD-INT 2023 - Delft3D User Days - Welcome - Day 3 - Afternoon by Deltares
DSD-INT 2023 - Delft3D User Days - Welcome - Day 3 - AfternoonDSD-INT 2023 - Delft3D User Days - Welcome - Day 3 - Afternoon
DSD-INT 2023 - Delft3D User Days - Welcome - Day 3 - Afternoon
Deltares13 views
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ... by Donato Onofri
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Donato Onofri711 views
A first look at MariaDB 11.x features and ideas on how to use them by Federico Razzoli
A first look at MariaDB 11.x features and ideas on how to use themA first look at MariaDB 11.x features and ideas on how to use them
A first look at MariaDB 11.x features and ideas on how to use them
Federico Razzoli45 views
DSD-INT 2023 FloodAdapt - A decision-support tool for compound flood risk mit... by Deltares
DSD-INT 2023 FloodAdapt - A decision-support tool for compound flood risk mit...DSD-INT 2023 FloodAdapt - A decision-support tool for compound flood risk mit...
DSD-INT 2023 FloodAdapt - A decision-support tool for compound flood risk mit...
Deltares13 views
Neo4j y GenAI by Neo4j
Neo4j y GenAI Neo4j y GenAI
Neo4j y GenAI
Neo4j42 views
El Arte de lo Possible by Neo4j
El Arte de lo PossibleEl Arte de lo Possible
El Arte de lo Possible
Neo4j38 views
DSD-INT 2023 Baseline studies for Strategic Coastal protection for Long Islan... by Deltares
DSD-INT 2023 Baseline studies for Strategic Coastal protection for Long Islan...DSD-INT 2023 Baseline studies for Strategic Coastal protection for Long Islan...
DSD-INT 2023 Baseline studies for Strategic Coastal protection for Long Islan...
Deltares11 views

#FrontConf2017 — Enhance your User (and Developer) Experience with React & Redux

  • 1. Enhance your User (and Developer) Experience with React & Redux & /phacks
  • 2. Hi! I am Nicolas Goutay. I work at Theodo, a web consultancy based in Paris & London. I build JS & Python web applications. I like music, typography and I have stage fright am excited to be here with all of you. You can find me online (Twitter & GitHub) on @phacks.
  • 3. React & Redux A Lego analogy
  • 4. React would be a Lego instruction manual, where bricks are DOM nodes. It takes care of how things look for the end user.
  • 5. test te fort veau jean jean humain loup travers des gout bon bonbon cher non How to build a F1
  • 6. On modern Web apps, how things look are usually a function of user interactions. In this analogy, the user is Elya, my 5 year-old niece. Red is her favorite color, so she wants the car to be red 🏎.
  • 7. This is where 🤖 Redux kicks in.
  • 8. # “I want the car to be red.” 🤖 “Dispatch the CHANGE_CAR_COLOR action with the payload color: red” $ “OK! I take note that you want your car red…” 🤖 “A reducer will process the action, and will add color: red to the Redux store” $ “…I sift through all the messy Legos to find red bricks…” 🤖 “The store passes the property color: red to React components” $ “…and I follow the instructions again with the red bricks”
  • 9. test te fort veau jean jean humain loup travers des gout bon bonbon cher non How to build a F1 Redux store color: red
  • 10. # “I want the car number to by my age, not yours” 🤖 “Dispatch the CHANGE_CAR_NUMBER action with the payload number: 5” $ “Oh there we go again. 5 it is…” 🤖 “A reducer will process the action, and will add number: 5 to the Redux store” $ “…Where on Earth did I put this sticker…” 🤖 “The store passes the property number: 5 to React components” $ “…there you go! Now go find your parents 😅”
  • 11. test te fort veau jean jean humain loup travers des gout bon bonbon cher non How to build a F1 Redux store color: red number: 5
  • 12. Redux — Now with actual code export function changeCarColor(color) { return { type: 'CHANGE_CAR_COLOR', color } } 🤖 “Dispatch the CHANGE_CAR_COLOR action with the payload color”
  • 13. Redux — Now with actual code function formulaOneApp(state = {}, action) { switch (action.type) { case 'CHANGE_CAR_COLOR': return Object.assign({}, state, { color: action.color }) default: return state } } 🤖 “A reducer will process the action, and will add color to the Redux store”
  • 14. Redux — Now with actual code 🤖 “The store passes the properties color and number to React components” import React from 'react' const FormulaOne = ({ color, number }) => ( <div> <CarBody color={color} /> <Decorations number={number} /> </div> )
  • 15. Developer Experience — Easier Debugging
  • 16. Developer Experience — Easier Debugging
  • 17. Developer Experience — Easier Debugging This is what the Redux Store of my current project look like. I can inspect every variable, which are updated in real time.
  • 18. User Experience — Built-in Performance
  • 19. User Experience — Built-in Performance React components are only repainted when their props or inner state change. React API methods like shouldComponentUpdate allow us to have a finer-grained control about render performance.
  • 20. Developer Experience — “Reasonaboutability”
  • 21. Developer Experience — “Reasonaboutability” React developer Jani Eväkallio coined the term “reasonaboutability” (easiness to reason about). I love it, and it matches perfectly what I feel about Redux. Here are the Three Principles of Redux:
  • 22. Developer Experience — “Reasonaboutability” React developer Jani Eväkallio coined the term “reasonaboutability” (easiness to reason about). I love it, and it matches perfectly what I feel about Redux. Here are the Three Principles of Redux: Single Source of Truth: all the data/UI state displayed on the app come from the same JS object. Facilitates debugging.
  • 23. Developer Experience — “Reasonaboutability” React developer Jani Eväkallio coined the term “reasonaboutability” (easiness to reason about). I love it, and it matches perfectly what I feel about Redux. Here are the Three Principles of Redux: Single Source of Truth: all the data/UI state displayed on the app come from the same JS object. Facilitates debugging. State is read-only: The only way to change the state is to emit an action, an object describing what happened. Provides a single, robust & semantic way to deal with interactions.
  • 24. Developer Experience — “Reasonaboutability” React developer Jani Eväkallio coined the term “reasonaboutability” (easiness to reason about). I love it, and it matches perfectly what I feel about Redux. Here are the Three Principles of Redux: Single Source of Truth: all the data/UI state displayed on the app come from the same JS object. Facilitates debugging. State is read-only: The only way to change the state is to emit an action, an object describing what happened. Provides a single, robust & semantic way to deal with interactions. Changes are made with pure functions: the Store can only be updated with pure functions (reducers). Prevents nasty side effects.
  • 25. Redux comes with other benefits — and tradeoffs
  • 26. 🤩 Tests are blissfully easy to write: Reducers are pure functions. Just test that given an input, they yield the right output. it('handles ADD_ITEM by adding the item', () => { const initialState = fromJS({ todos: [ {id: 1, text: 'React', status: 'active'} ] }); const action = { type: 'ADD_ITEM', text: 'Redux' } const nextState = reducer(initialState, action); expect(nextState).to.equal(fromJS({ todos: [ {id: 1, text: 'React', status: 'active'}, {id: 2, text: 'Redux', status: 'active'}, ] })); });
  • 27. 🛠 Rich ecosystem: Redux has an API to plug-in middlewares. There are tons of them: for logging, offline capabilities, async, forms, optimistic UIs… Tip: 🔗 github.com/markerikson/react-redux-links is a great place to start!
  • 28. 🤓 Code structure is key: Since all UI is derived from a single JS object, it needs to be carefully designed and constantly adjusted to business requirements. Tip: Learn from the best! Twitter & Pinterest both use Redux, and the structure is available for anybody to see with the React Dev Tools!
  • 29. Tip: I just got used to it. After a while it even feels more productive than Angular 1, because you know exactly what to do to get everything to work together. 😓 Verbosity: to write a feature, you would usually need to write an action, a reducer, a selector, a saga… It feels quite cumbersome compared to Angular 1.
  • 30. Conclusion React with Redux is a mature framework that empowers developers to produce better apps in a much better way.
  • 31. Want to dive in? I wrote a full-featured, test-driven tutorial on writing a Todo List using React & Redux 🔗 http://github.com/phacks/redux-todomvc
  • 32. Danke! Slides are available at phacks.github.io & /phacks