Member-only story
Redux for beginners
3 min readDec 19, 2024
Read for free : https://medium.com/@pratikkumar399/redux-for-beginners-4883eea242f9?sk=1ee7008d3a7c102f0427999230842355
Redux is a state management library for JavaScript apps, commonly used with React but also compatible with other libraries.
Core Concepts
- Store: Holds the entire application state. It is a single source of truth, making state management predictable and centralized.
- Actions: Plain JavaScript objects that describe events or changes in the app. Actions must have a
type
property (a string constant), and they may also carry additional data (payload). - Reducers: Pure functions that take the current state and an action as inputs, and return a new state. They describe how the state should change in response to an action.
- Dispatch: A function used to send actions to the store. When an action is dispatched, the store forwards it to the reducers to update the state.
- Selectors: Functions used to extract specific pieces of data from the store.
Redux Flow
- A component dispatches an action.
- The action is sent to the reducer.
- The reducer calculates the new state based on the action.
- The store is updated with the new…