SlideShare a Scribd company logo
REACT STATE MANAGEMENT
WITH REDUX
React state managmenet with Redux
React state managmenet with Redux
Vedran Blaženka
Front-End Developer at Enterwell.
JavaScript, React, Redux, CSS Modules,
PostCSS, Elm...
enterwell.net/careers/
STATE MANAGEMENT IS HARD
Tracking server responses
Cached data
Tracking local data
UI state, Show/hide spinner, active
route...
server-side rendering, fetching data
before performing route transitions
etc...
React
Communication between components
PREDICTABLE STATE CONTAINER
Predictable
Make state mutations predictable by putting
restrictions on how and when updates can
happen.
(actions, reducers)
React state managmenet with Redux
Redux's Three Principles
Single source of truth
The of your whole application is stored in an
object tree within a single .
state
store
State is read-only
The only way to change the state is to emit an ,
an object describing what have or should happened.
action
Changes are made with
pure functions
To specify how the state tree is transformed by actions,
you write pure .reducers
Data Flow
strict unidirectional data flow
React state managmenet with Redux
Actions
{
type: 'ADD_TODO',
payload: {
text: 'Build my first Redux app'
}
}
https://github.com/acdlite/flux-standard-action
1. Something has (or should) happen
2. Don't specify how
Action Creator
function addTodo(text) {
return {
type: 'ADD_TODO',
payload: {
text
}
}
}
store.dispatch(addTodo('Write blog post'));
Reducer
(previousState, action) => newState
Pure function that takes the previous state,
and an action and returns the new state.
React state managmenet with Redux
function todoReducer(state = [], action) {
switch(action.type) {
case 'ADD_TODO':
return [ ...state, action.payload ];
case default:
return state;
}
}
export default todoReducer;
function addTodo(text) {
return {
type: 'ADD_TODO',
payload: {
text
}
}
}
store.dispatch(addTodo('Write blog post'));
Things you should never do inside a reducer:
Mutate its arguments;
Perform side effects like API calls and routing
transitions;
Call non-pure functions, e.g. Date.now() or
Math.random().
Just a calculation!
Immutability
No surprises. No side effects. No API
calls. No mutations.
Store
getState()
dispatch(action)
subscribe(listener)
replaceReducer(nextReducer)
State vs. Store
Do whatever is less awkward. - Adam Abramov
http://redux.js.org/docs/faq/OrganizingState.
html#organizing-state-only-redux-state
Marc was almost ready to implement
his "hello world" React/Redux app
React state managmenet with Redux
TO BE, OR NOT TO BE
(to redux, or not)
Pros:
Total separation of data and UI
Server-side rendering
Developer Experience (DevTools, Time Travel, Logging)
Growing ecosystem
Easy error reporting integration with other services
(Sentry)
Strinct unidirectional data flow
Redux API - 99 lines of code
Cons:
Community conventions are still developing
"Feels bloated, too much boilerplate code..."
¯_( )_/¯ (shrug emoji)
http://redux.js.org/
https://egghead.io/courses/getting-started-
with-redux
https://facebook.github.io/immutable-js/
https://github.com/reactjs/react-redux
https://github.com/gaearon/redux-thunk
Resources (za one koji žele znati više) :
Hvala na pažnji!
Vedran Blaženka
@vblazenka
blazenka.vedran@gmail.com

More Related Content

PPTX
React / Redux Architectures
PDF
React and redux
PDF
React JS and Redux
PDF
React js
PPTX
Introduction to react and redux
PPTX
Introduction to React JS for beginners
PPTX
Redux workshop
PPTX
React/Redux
React / Redux Architectures
React and redux
React JS and Redux
React js
Introduction to react and redux
Introduction to React JS for beginners
Redux workshop
React/Redux

What's hot (20)

PPT
Basic using of Swing in Java
PPTX
Spring Boot & WebSocket
PPTX
Introduction to Spring Boot
PPTX
React + Redux Introduction
PDF
Introduction to Redux
PDF
Support cours angular
PPTX
PDF
Introduction to react native
PDF
Support POO Java Deuxième Partie
PPT
Hibernate architecture
PPTX
React workshop
PPTX
Introduction to React JS
PPTX
Intro to React
PPTX
[Final] ReactJS presentation
PDF
React redux-tutoriel-1
PPTX
Better web apps with React and Redux
PDF
React + Redux for Web Developers
PPTX
React JS: A Secret Preview
PDF
Spring Framework - Core
PPTX
React native
Basic using of Swing in Java
Spring Boot & WebSocket
Introduction to Spring Boot
React + Redux Introduction
Introduction to Redux
Support cours angular
Introduction to react native
Support POO Java Deuxième Partie
Hibernate architecture
React workshop
Introduction to React JS
Intro to React
[Final] ReactJS presentation
React redux-tutoriel-1
Better web apps with React and Redux
React + Redux for Web Developers
React JS: A Secret Preview
Spring Framework - Core
React native
Ad

Similar to React state managmenet with Redux (20)

PDF
Understanding redux
PPTX
unit 2 Mastering-State-Management-in-React.pptx
PDF
Redux essentials
PPTX
Redux training
PPTX
Getting started with Redux js
PDF
Let's discover React and Redux with TypeScript
PPTX
Redux Like Us
PDF
Building React Applications with Redux
PPTX
STATE MANAGEMENT IN REACT [Autosaved].pptx
PDF
Getting started with React and Redux
PDF
Making react part of something greater
PPTX
Academy PRO: React JS. Redux & Tooling
PDF
Manage the Flux of your Web Application: Let's Redux
PPTX
Reducers+flux=redux
PDF
Redux js
PDF
React.js and Redux overview
PDF
React state management with Redux and MobX
PDF
react redux.pdf
PDF
[@NaukriEngineering] Flux Architecture
PDF
2018 02-22 React, Redux & Building Applications that Scale | Redux
Understanding redux
unit 2 Mastering-State-Management-in-React.pptx
Redux essentials
Redux training
Getting started with Redux js
Let's discover React and Redux with TypeScript
Redux Like Us
Building React Applications with Redux
STATE MANAGEMENT IN REACT [Autosaved].pptx
Getting started with React and Redux
Making react part of something greater
Academy PRO: React JS. Redux & Tooling
Manage the Flux of your Web Application: Let's Redux
Reducers+flux=redux
Redux js
React.js and Redux overview
React state management with Redux and MobX
react redux.pdf
[@NaukriEngineering] Flux Architecture
2018 02-22 React, Redux & Building Applications that Scale | Redux
Ad

Recently uploaded (20)

PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
Introduction to Artificial Intelligence
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
ai tools demonstartion for schools and inter college
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
System and Network Administraation Chapter 3
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPT
Introduction Database Management System for Course Database
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
L1 - Introduction to python Backend.pptx
PPTX
history of c programming in notes for students .pptx
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
Online Work Permit System for Fast Permit Processing
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Introduction to Artificial Intelligence
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
VVF-Customer-Presentation2025-Ver1.9.pptx
PTS Company Brochure 2025 (1).pdf.......
Odoo POS Development Services by CandidRoot Solutions
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
ai tools demonstartion for schools and inter college
CHAPTER 2 - PM Management and IT Context
System and Network Administraation Chapter 3
Design an Analysis of Algorithms II-SECS-1021-03
Introduction Database Management System for Course Database
Upgrade and Innovation Strategies for SAP ERP Customers
L1 - Introduction to python Backend.pptx
history of c programming in notes for students .pptx
Understanding Forklifts - TECH EHS Solution
Online Work Permit System for Fast Permit Processing
Operating system designcfffgfgggggggvggggggggg
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises

React state managmenet with Redux