Redux Club degli Sviluppatori

17
Redux Giuseppe Santoro

Transcript of Redux Club degli Sviluppatori

ReduxGiuseppe Santoro

Redux is a predictable state container for JavaScript apps

What is a state?

What is a state?

What is a state?

Action: add a Task

New state

States

S1S2

S3

S5S4

A1 A2

A3A4

A5

A6

Motivation

Our code must manage more state than ever before

Three Principles

Single source of truth

Three Principles

Single source of truth

State is read-only

Three Principles

Single source of truth

State is read-only

Changes are made with pure functions

Functions that return the exact same output for given inputs

They should also be free of side-effects

Pure Function

Code Example

Demo