Redux Flashcards
When is redux useful ?
Redux is more useful when: (4)
You have large amounts of application state that are needed in many places in the app
The app state is updated frequently over time
The logic to update that state may be complex
The app has a medium or large-sized codebase, and might be worked on by many people
What is Redux ?
library used for updating and managing application state, using events called “actions”.It serves as a centralized store for state that needs to be used across your entire application, with rules ensuring that the state can only be updated in a predictable fashion.
Action
An action is a plain JavaScript object that has a type field. You can think of an action as an event that describes something that happened in the application.
Reducers
A reducer is a function that receives state and action and decide how to update state if necessary and returns the new state: (state, action) => newState (think as an event listener)
Store
The current Redux application state lives in an object called the store .
Dispatch
the only way to update state is to call store.dispatch() and pass an action object.
You can think of dispatching actions as “triggering an event” in the application. Something happened, and we want the store to know about it.
Redux Slices
list of reducers of the same category
Selectors
Selectors are functions that know how to extract specific pieces of information from a store state value.