How Redux internally works?
4 min readSep 21, 2024
Redux is one of the difficult topics to understand. I will try to compare Redux with regular variable to understand better as most of you know how regular variable works. You can check here on what is Redux.
Regular Variables
- When to Store: You store values in variables based on the needs of your application logic.
- What to Store: You store the actual value you need.
- How to Store: You store values by assigning them to variables (e.g.,
let a = 1;
). - Where to Store: Values are stored in memory.
Example:
let a = 1; // Declare variable `a` with initial value 1
let b = 3; // Assign value 3 to variable `b`
let c = a + b; // Assign the result of `a + b` to `c`
console.log(c); // Output: 4
Redux Store
Redux is a state management library used in JavaScript applications, typically with React. It handles state differently from regular variables and is more suited for managing complex state across your application.
- When to Store: In Redux, the state is stored based on the actions and updates triggered by your application. State updates happen through actions and reducers.
- What to Store: The state managed by Redux contains data that your…