SlideShare a Scribd company logo
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

More Related Content

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

PDF
Connecting with the enterprise - The how and why of connecting to Enterprise ...
Kevin Poorman
 
PPTX
Rethinking Best Practices
floydophone
 
PPTX
All a flutter about Flutter.io
Steven Cooper
 
PDF
Mobile App Feature Configuration and A/B Experiments
lacyrhoades
 
PDF
Huge web apps web expo 2013
Daniel Steigerwald
 
PDF
High Performance web apps in Om, React and ClojureScript
Leonardo Borges
 
PDF
Simple React Todo List
Ritesh Chaudhari
 
PDF
Intro to BackboneJS + Intermediate Javascript
Andrew Lovett-Barron
 
PPTX
React js - The Core Concepts
Divyang Bhambhani
 
PPTX
Rubyconf2016 - Solving communication problems in distributed teams with BDD
Rodrigo Urubatan
 
PDF
The State of Front-end At CrowdTwist
Mark Fayngersh
 
PDF
React && React Native workshop
Stacy Goh
 
PDF
Plugin for Plugin, или расширяем Android New Build System. Антон Руткевич
Yandex
 
PDF
Connect.js - Exploring React.Native
joshcjensen
 
PDF
N Things You Don't Want to Repeat in React Native
Anton Kulyk
 
PDF
Let's discover React and Redux with TypeScript
Mathieu Savy
 
PDF
Professional JavaScript: AntiPatterns
Mike Wilcox
 
PDF
resolvendo problemas de comunicação em equipes distribuídas com bdd
Rodrigo Urubatan
 
PDF
Intro to React - Featuring Modern JavaScript
jasonsich
 
PPTX
Adding a modern twist to legacy web applications
Jeff Durta
 
Connecting with the enterprise - The how and why of connecting to Enterprise ...
Kevin Poorman
 
Rethinking Best Practices
floydophone
 
All a flutter about Flutter.io
Steven Cooper
 
Mobile App Feature Configuration and A/B Experiments
lacyrhoades
 
Huge web apps web expo 2013
Daniel Steigerwald
 
High Performance web apps in Om, React and ClojureScript
Leonardo Borges
 
Simple React Todo List
Ritesh Chaudhari
 
Intro to BackboneJS + Intermediate Javascript
Andrew Lovett-Barron
 
React js - The Core Concepts
Divyang Bhambhani
 
Rubyconf2016 - Solving communication problems in distributed teams with BDD
Rodrigo Urubatan
 
The State of Front-end At CrowdTwist
Mark Fayngersh
 
React && React Native workshop
Stacy Goh
 
Plugin for Plugin, или расширяем Android New Build System. Антон Руткевич
Yandex
 
Connect.js - Exploring React.Native
joshcjensen
 
N Things You Don't Want to Repeat in React Native
Anton Kulyk
 
Let's discover React and Redux with TypeScript
Mathieu Savy
 
Professional JavaScript: AntiPatterns
Mike Wilcox
 
resolvendo problemas de comunicação em equipes distribuídas com bdd
Rodrigo Urubatan
 
Intro to React - Featuring Modern JavaScript
jasonsich
 
Adding a modern twist to legacy web applications
Jeff Durta
 

Recently uploaded (20)

PPTX
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PPTX
Revolutionizing Code Modernization with AI
KrzysztofKkol1
 
PDF
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
PPTX
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PDF
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
PPTX
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
PDF
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
PPTX
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PDF
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
Human Resources Information System (HRIS)
Amity University, Patna
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Revolutionizing Code Modernization with AI
KrzysztofKkol1
 
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
Tally software_Introduction_Presentation
AditiBansal54083
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Ad

#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