SlideShare a Scribd company logo
State Models for React
Stephan Schmidt
übercto
@codemonkeyism
Stephan Schmidt
Started
Programming
Computer
Science
University
Demo
Scene
Interactiva
PIN
Computer
Science &
Philosophy
University
Retraining
Teacher
Startup
Fraunhofer
Immobilien-
Scout24
brands4friends
eBay
eventsofa
• Framework[1] by Facebook
• The V in MVC (Rendering HTML)
• Promises to unifyiOS, Android and Web
• Wrote backend app for eventsofa
• Steep learning curve,mostly due to state
• Concepts
– Components
– Props
– State
– JSX
React
[1]	Framework	and Library	http://martinfowler.com/bliki/InversionOfControl.html
States - Web App with Server
HTML
(value)
Backend
(DB)
submit/
POST
render
State Buckets
HTML
(value)
Component
(this.state)
App
(store)
Backend
(DB)
Local Storage
(browser/app)
Syncing & State Flow
HTML
(value)
Component
(this.state)
App
(store)
Backend
(DB)
Local Storage
(browser/app)
React Unidirectional Data Flow
Component
(this.props)
Component
(this.props)
React/ render
(props)
React/ render
(props)
HTML
(value)
Component
(this.props)
Example App
React Libraries in Browser Without Build Tools
Component Tree
CommentBox
CommentList
Comment
Comment
CommentTitle
CommentTitle
React Components
React App
Example App With State
Unidirectional Flow With State
Component
(this.state)
Component
(this.props)
Component
(this.props)
React/ render
(props)
React/ render
(props)
React/ render
(props)
HTML
(value)
Component
(this.props)
React Components With State
Example App With Mutable State
React App With Mutable State
HTML
(value)
Component
(this.state)
Component
(this.state)
React/
render
onChange/
setState
Component
(this.state)
React/
render
setState
setState
https://facebook.github.io/react/docs/two-way-binding-helpers.html
Mixing State and Props
makes things confusing
• Use only props in components
• ‘Root’ component has state
• Why?
– State makes components difficult to test
– State makes components difficult to reason about
– State makes it too easy to put business logic in the
component
– State makes it difficult to share information to other parts
of the app
Stateless Components
https://camjackson.net/post/9-things-every-reactjs-beginner-should-know
React App With Mutable State in Root Component
HTML
(value)
Component
(this.props)
Component
(this.state)
React/
render
React/
render
onChange/
setState
Component
(this.props)
React/
render
ReactRootComponentHasState
Update Function Pushed Down
Component With onChange
React Developer Tools
• Clean unidirectional flow
• Changes in one place
• State transitions:
– stateNew = stateOld + changes
• State can easily be debugged
Redux
• Action Types, Actions and Action Creators
• Reducers
• App
• Mappers
• Store
Redux Concepts
Redux Example
Example App
Redux	Developer	Tools
React App with Redux
HTML
(value)
Component
(this.props)
App
(store)
React/
render
onChange
Redux
stateToProps
Mapping
dispatch Action
+ Reducer
Component
(this.props)
React/
render
Actions and Reducers
Redux App
React Components Without State, only Props
React Components Wired To Store
Wiring Redux Store to React Props
React Immutability Helpers
React/Redux With AJAX Backend
e.g. Thunk
middleware
HTML
(value)
Component
(this.state)
App
(store)
Backend
(DB)
React/
render
onChange/
setState
Redux
Action/
Reducer
componentDidMount/
HTTP GET
onSubmit/
HTTP POST
Action/
Reducer
Action/
Reducer
Component
(this.props)
React/
render
With AJAX
Flickr Brandon Atkinson CC BY 2.0
• Unidirectional flow -> Jipee!
• Mutable state? -> this.state
• Confusing props and state? -> Redux
• Complex state -> Immutable.js / Immutabilityhelpers
• Side effects in pure functions?-> Middleware/Thunk
• Boilerplate?-> Magic
• Magic Boilerplate?-> More Magic
• Many dependencies?-> Toolchain (Babel, Webpack, ...)
How did we get here?
Also	see	Haskell:	Pure	functions?	Jipee!	Side	Effects?	Monads!	Complex	side	effects?
Monad	Transformers!	...
Some more thoughts …
When to sync?
Granularity to sync?
How to sync?
Sync = replication & persistence
Sync is visibility to others
Complexity?
HTML
(value)
Backend
(DB)
submit/
POST
Web App with Server
render
e.g. Thunk
middleware
HTML
(value)
Component
(this.state)
App
(store)
Backend
(DB)
React/
render
onChange/
setState
Redux
React/Redux with AJAX Backend
and ‚save‘ on submit forms
Action/
Reducer
componentDidMount/
HTTP GET
onSubmit/
HTTP POST
Action/
Reducer
Action/
Reducer
Component
(this.props)
React/
render
Stephan Schmidt
@codemonkeyism
stephan@ubercto.de

More Related Content

What's hot (20)

PDF
Using redux
Jonas Ohlsson Aden
 
PDF
Let's Redux!
Joseph Chiang
 
PPTX
Getting started with Redux js
Citrix
 
PDF
React.js and Redux overview
Alex Bachuk
 
PDF
The Road To Redux
Jeffrey Sanchez
 
PDF
Introduction to React & Redux
Boris Dinkevich
 
PDF
Redux Universal
Nikolaus Graf
 
PDF
Introduction to Redux
Ignacio Martín
 
PDF
React for Dummies
Mitch Chen
 
PDF
React state managmenet with Redux
Vedran Blaženka
 
PDF
React redux
Michel Perez
 
PDF
React + Redux. Best practices
Clickky
 
PPTX
React / Redux Architectures
Vinícius Ribeiro
 
PPTX
Academy PRO: React JS. Redux & Tooling
Binary Studio
 
PDF
Angular redux
Nir Kaufman
 
PPTX
Introduction to react and redux
Cuong Ho
 
PPTX
Redux training
dasersoft
 
PPTX
React with Redux
Stanimir Todorov
 
PPTX
React & redux
Cédric Hartland
 
PPTX
Better web apps with React and Redux
Ali Sa'o
 
Using redux
Jonas Ohlsson Aden
 
Let's Redux!
Joseph Chiang
 
Getting started with Redux js
Citrix
 
React.js and Redux overview
Alex Bachuk
 
The Road To Redux
Jeffrey Sanchez
 
Introduction to React & Redux
Boris Dinkevich
 
Redux Universal
Nikolaus Graf
 
Introduction to Redux
Ignacio Martín
 
React for Dummies
Mitch Chen
 
React state managmenet with Redux
Vedran Blaženka
 
React redux
Michel Perez
 
React + Redux. Best practices
Clickky
 
React / Redux Architectures
Vinícius Ribeiro
 
Academy PRO: React JS. Redux & Tooling
Binary Studio
 
Angular redux
Nir Kaufman
 
Introduction to react and redux
Cuong Ho
 
Redux training
dasersoft
 
React with Redux
Stanimir Todorov
 
React & redux
Cédric Hartland
 
Better web apps with React and Redux
Ali Sa'o
 

Similar to State Models for React with Redux (20)

PDF
React&redux
Blank Chen
 
PDF
React JS and why it's awesome
Andrew Hull
 
PPTX
TRAINING pptt efwoiefo weoifjoiewjfoifjow.pptx
PrathamSharma77833
 
PDF
Materi Modern React Redux Power Point.pdf
exiabreak
 
PDF
react-slides.pdf
DayNightGaMiNg
 
PDF
react-slides.pdf gives information about react library
janet736113
 
PPTX
react-slidlkjfl;kj;dlkjopidfjhopijgpoerjpofjiwoepifjopweifjepoies.pptx
PrathamSharma77833
 
PPTX
STATE MANAGEMENT IN REACT [Autosaved].pptx
siddheshjadhav919123
 
PDF
A React Journey
LinkMe Srl
 
PPTX
React/Redux
Durgesh Vaishnav
 
PPTX
react-slides.pptx
DayNightGaMiNg
 
PDF
Corso su ReactJS
LinkMe Srl
 
PPTX
The productive developer guide to React
Maurice De Beijer [MVP]
 
PDF
React and redux
Mystic Coders, LLC
 
PDF
ReactRedux.pdf
Arsalan malik
 
PPTX
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
Karmanjay Verma
 
PPTX
React State vs Props Introduction & Differences.pptx
BOSC Tech Labs
 
PDF
theory-slides-vueh3urh4ur4ur4r44oirj4riu4ri
paridhiagarwal129
 
PDF
React state management with Redux and MobX
Darko Kukovec
 
PDF
Introduction to Redux (for Angular and React devs)
Fabio Biondi
 
React&redux
Blank Chen
 
React JS and why it's awesome
Andrew Hull
 
TRAINING pptt efwoiefo weoifjoiewjfoifjow.pptx
PrathamSharma77833
 
Materi Modern React Redux Power Point.pdf
exiabreak
 
react-slides.pdf
DayNightGaMiNg
 
react-slides.pdf gives information about react library
janet736113
 
react-slidlkjfl;kj;dlkjopidfjhopijgpoerjpofjiwoepifjopweifjepoies.pptx
PrathamSharma77833
 
STATE MANAGEMENT IN REACT [Autosaved].pptx
siddheshjadhav919123
 
A React Journey
LinkMe Srl
 
React/Redux
Durgesh Vaishnav
 
react-slides.pptx
DayNightGaMiNg
 
Corso su ReactJS
LinkMe Srl
 
The productive developer guide to React
Maurice De Beijer [MVP]
 
React and redux
Mystic Coders, LLC
 
ReactRedux.pdf
Arsalan malik
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
Karmanjay Verma
 
React State vs Props Introduction & Differences.pptx
BOSC Tech Labs
 
theory-slides-vueh3urh4ur4ur4r44oirj4riu4ri
paridhiagarwal129
 
React state management with Redux and MobX
Darko Kukovec
 
Introduction to Redux (for Angular and React devs)
Fabio Biondi
 
Ad

More from Stephan Schmidt (11)

PDF
Focus, Focus, Focus - The one thing that makes a difference
Stephan Schmidt
 
PDF
Employee Live Cycle JAX 2016
Stephan Schmidt
 
PDF
Short Guide to Productivity
Stephan Schmidt
 
PDF
10 Years of My Scrum Experience
Stephan Schmidt
 
PDF
What Top Management Needs to Know About IT
Stephan Schmidt
 
PDF
What managers need_to_know
Stephan Schmidt
 
PDF
What everyone should know about time to market
Stephan Schmidt
 
PDF
LMAX Architecture
Stephan Schmidt
 
PDF
Developer Testing
Stephan Schmidt
 
PDF
Better Strategies for Null Handling in Java
Stephan Schmidt
 
PDF
Berlin.JAR: Web future without web frameworks
Stephan Schmidt
 
Focus, Focus, Focus - The one thing that makes a difference
Stephan Schmidt
 
Employee Live Cycle JAX 2016
Stephan Schmidt
 
Short Guide to Productivity
Stephan Schmidt
 
10 Years of My Scrum Experience
Stephan Schmidt
 
What Top Management Needs to Know About IT
Stephan Schmidt
 
What managers need_to_know
Stephan Schmidt
 
What everyone should know about time to market
Stephan Schmidt
 
LMAX Architecture
Stephan Schmidt
 
Developer Testing
Stephan Schmidt
 
Better Strategies for Null Handling in Java
Stephan Schmidt
 
Berlin.JAR: Web future without web frameworks
Stephan Schmidt
 
Ad

Recently uploaded (20)

PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Digital Circuits, important subject in CS
contactparinay1
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 

State Models for React with Redux