SlideShare a Scribd company logo
Introduction to Redux
Kate Kilian || Full-stack JS Engineer
Background
&
Theory
What’s the need for Redux,
and why is it a useful solution?
First: State Management
The problem:
How should one manage client-side state?
Types of state to manage:
● Data-driven
● Communication-driven
● Controls (forms, per-view)
● Session
React’s out-of-the-box
setState()
doesn’t work well
for ALL state types
Other attempts to “solve” state-management
Flux:
Stores emit events; components must handle their
own listening/updating.
MobX:
Provides stores, uses observables to get updates; has
less boilerplate via decorators.
“Pub-Sub”:
Any component can publish an event and/or
subscribe; all publishing and subscribing is managed by each
component.
What types of apps does Redux work for?
… where there’s state to manage!
● Single-page web applications (SPAs)
● Desktop apps via Electron
● React Native apps
Principles behind Redux’s architecture choices
Single Source of Truth via Unidirectional Data Flow
=> all actions are consolidated by reducer
=> reducer handles changes to Redux state
=> predictable logic across app
=> data normalization (decreases likelihood of multiple copies of data)
State is “Read Only” using Immutability
=> reducer returns a new state - no callbacks modifying state in place
State is modified using Pure Functions
=> same inputs, predictable output
Major benefits of Redux
Immutability enables new functionality:
● Timeline and time travel
○ Data goldmine!
○ Debugging with Redux
Devtools/Logging
○ Better understanding of your app
○ Can send bug report
○ Hook into analytics
● Easier testing due to “pure functions”
● Enables clean diff-ing for
component update
Connect():
● abstracts event listener logic
● Component receives data for specific
parts of store
Dispatch():
● Calls reducer with
the action passed to dispatch
● Used under the covers in
mapDispatchToProps
Takeaway:
In larger apps with more complexity,
constraints help the app FLOURISH!
Project Setup How to begin using Redux
in your app
… npm install is your friend
React projects
npm install redux
npm install react-redux
Other JS projects
Angular:
Ng-redux
ng2-redux
Vue.js:
Vue-redux
Vuedux
Redux Demo
● Store
● Provider
● connect()
● dispatch()
● Action creators
● Actions
● Reducers
All the parts and how to use them
Gotchas
What to watch out for
● Don’t mutate state in place
● Flatten state tree using normalizr
Thanks for
listening!
… and stay in touch
Demo App & Resources
https://github.com/katekilian/
react-redux-mini-bookreader
Kate Kilian
Twitter: @thequirkyquail
Github: https://github.com/katekilian
LinkedIn: http://linkedin.com/in/katekilian
… and when SHOULDN’T you use Redux?
Static sites, where there’s no state to manage
Situations where a view’s/component’s internal state
doesn’t need to be broadcast to other components
If you don’t agree with the philosophies
and want more control with less “ceremony”

More Related Content

PDF
Getting started with React and Redux
PDF
React Redux Interview Questions PDF By ScholarHat
PDF
React Redux Interview Questions PDF By ScholarHat
PDF
Using redux
PDF
How to Redux
PDF
Redux in Angular 2+
PPTX
an Introduction to Redux
PPTX
downloads_introduction to redux.pptx
Getting started with React and Redux
React Redux Interview Questions PDF By ScholarHat
React Redux Interview Questions PDF By ScholarHat
Using redux
How to Redux
Redux in Angular 2+
an Introduction to Redux
downloads_introduction to redux.pptx

Similar to Introduction to Redux.pptx (20)

PDF
Introduction to Redux (for Angular and React devs)
PDF
ReactRedux.pdf
PDF
Understanding redux
PPTX
U3-02-React Redux and MUI.pptxaSDFGNXDASDFG
PDF
React.js and Redux overview
PDF
React Redux Tutorial | Redux Tutorial for Beginners | React Redux Training | ...
PDF
#FrontConf2017 — Enhance your User (and Developer) Experience with React & Redux
PDF
Let's discover React and Redux with TypeScript
PPTX
Academy PRO: React JS. Redux & Tooling
PPT
The Redux Introduction in react and applications .
PDF
Redux and context api with react native app introduction, use cases, implemen...
PDF
The Road To Redux
PDF
Redux essentials
PPTX
Redux Tech Talk
PDF
Materi Modern React Redux Power Point.pdf
PDF
An Introduction to Redux
PDF
Redux State Management System A Comprehensive Review
PDF
State of the state
PPTX
Reducers+flux=redux
PPTX
Introduction to react and redux
Introduction to Redux (for Angular and React devs)
ReactRedux.pdf
Understanding redux
U3-02-React Redux and MUI.pptxaSDFGNXDASDFG
React.js and Redux overview
React Redux Tutorial | Redux Tutorial for Beginners | React Redux Training | ...
#FrontConf2017 — Enhance your User (and Developer) Experience with React & Redux
Let's discover React and Redux with TypeScript
Academy PRO: React JS. Redux & Tooling
The Redux Introduction in react and applications .
Redux and context api with react native app introduction, use cases, implemen...
The Road To Redux
Redux essentials
Redux Tech Talk
Materi Modern React Redux Power Point.pdf
An Introduction to Redux
Redux State Management System A Comprehensive Review
State of the state
Reducers+flux=redux
Introduction to react and redux
Ad

Recently uploaded (20)

PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
Classroom Observation Tools for Teachers
PPTX
Digestion and Absorption of Carbohydrates, Proteina and Fats
PDF
advance database management system book.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Introduction to Building Materials
PDF
SOIL: Factor, Horizon, Process, Classification, Degradation, Conservation
PDF
Trump Administration's workforce development strategy
PDF
Hazard Identification & Risk Assessment .pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Empowerment Technology for Senior High School Guide
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PPTX
Unit 4 Skeletal System.ppt.pptxopresentatiom
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PDF
IGGE1 Understanding the Self1234567891011
PDF
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
Classroom Observation Tools for Teachers
Digestion and Absorption of Carbohydrates, Proteina and Fats
advance database management system book.pdf
Supply Chain Operations Speaking Notes -ICLT Program
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
A systematic review of self-coping strategies used by university students to ...
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Introduction to Building Materials
SOIL: Factor, Horizon, Process, Classification, Degradation, Conservation
Trump Administration's workforce development strategy
Hazard Identification & Risk Assessment .pdf
Final Presentation General Medicine 03-08-2024.pptx
Empowerment Technology for Senior High School Guide
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
Unit 4 Skeletal System.ppt.pptxopresentatiom
LDMMIA Reiki Yoga Finals Review Spring Summer
IGGE1 Understanding the Self1234567891011
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
Ad

Introduction to Redux.pptx

  • 1. Introduction to Redux Kate Kilian || Full-stack JS Engineer
  • 2. Background & Theory What’s the need for Redux, and why is it a useful solution?
  • 4. The problem: How should one manage client-side state? Types of state to manage: ● Data-driven ● Communication-driven ● Controls (forms, per-view) ● Session React’s out-of-the-box setState() doesn’t work well for ALL state types
  • 5. Other attempts to “solve” state-management Flux: Stores emit events; components must handle their own listening/updating. MobX: Provides stores, uses observables to get updates; has less boilerplate via decorators. “Pub-Sub”: Any component can publish an event and/or subscribe; all publishing and subscribing is managed by each component.
  • 6. What types of apps does Redux work for? … where there’s state to manage! ● Single-page web applications (SPAs) ● Desktop apps via Electron ● React Native apps
  • 7. Principles behind Redux’s architecture choices Single Source of Truth via Unidirectional Data Flow => all actions are consolidated by reducer => reducer handles changes to Redux state => predictable logic across app => data normalization (decreases likelihood of multiple copies of data) State is “Read Only” using Immutability => reducer returns a new state - no callbacks modifying state in place State is modified using Pure Functions => same inputs, predictable output
  • 8. Major benefits of Redux Immutability enables new functionality: ● Timeline and time travel ○ Data goldmine! ○ Debugging with Redux Devtools/Logging ○ Better understanding of your app ○ Can send bug report ○ Hook into analytics ● Easier testing due to “pure functions” ● Enables clean diff-ing for component update Connect(): ● abstracts event listener logic ● Component receives data for specific parts of store Dispatch(): ● Calls reducer with the action passed to dispatch ● Used under the covers in mapDispatchToProps
  • 9. Takeaway: In larger apps with more complexity, constraints help the app FLOURISH!
  • 10. Project Setup How to begin using Redux in your app
  • 11. … npm install is your friend React projects npm install redux npm install react-redux Other JS projects Angular: Ng-redux ng2-redux Vue.js: Vue-redux Vuedux
  • 12. Redux Demo ● Store ● Provider ● connect() ● dispatch() ● Action creators ● Actions ● Reducers All the parts and how to use them
  • 13. Gotchas What to watch out for ● Don’t mutate state in place ● Flatten state tree using normalizr
  • 14. Thanks for listening! … and stay in touch Demo App & Resources https://github.com/katekilian/ react-redux-mini-bookreader Kate Kilian Twitter: @thequirkyquail Github: https://github.com/katekilian LinkedIn: http://linkedin.com/in/katekilian
  • 15. … and when SHOULDN’T you use Redux? Static sites, where there’s no state to manage Situations where a view’s/component’s internal state doesn’t need to be broadcast to other components If you don’t agree with the philosophies and want more control with less “ceremony”