React — React Redux - Introduction
Redux is a state management library often used with React. It helps manage global state in large applications using actions, reducers, and a store.
import { createStore } from 'redux';
const reducer = (state = { count: 0 }, action) => {
switch (action.type) {
case 'INCREMENT':
return { count: state.count + 1 };
default:
return state;
}
};
const store = createStore(reducer);
store.dispatch({ type: 'INCREMENT' });
console.log(store.getState());