The document discusses Redux, a state management library for JavaScript applications. It explains the three main principles of Redux - single source of truth for state, state is read-only, and changes are made with pure functions called reducers. It then provides an example of building a counter with Redux, including creating an action type, reducer, and using the store to dispatch actions and access the current state.
55. action ‘INCREMENT’ => plus 1
action ‘DECREMENT’ => minus 1
action ‘UNKNOWN’ => previous state
Creating a
counter
56. action ‘INCREMENT’ => plus 1
action ‘DECREMENT’ => minus 1
action ‘UNKNOWN’ => previous state
state undefined => initial state (0)
Creating a
counter
71. store
methods
import { createStore } from 'redux';
import counter from './reducers/counter';
const store = createStore(counter);
console.log(store.getState()); // 0