Redux Flashcards
Redux can be described in three fundamental principles:
- single source of truth
- state is read only
- changes are made with pure functions
Single source of truth
The global state of your application is stored in an object tree within a single store.
State is read-only
The only way to change the state is to emit an action, an object describing what happened.
Changes are made with pure functions
Reducers are just pure functions that take the previous state and an action, and return the next state
What is Redux
Redux is a pattern and library for managing and updating application state, using events called “actions”.
Why I need Redux
Redux helps you manage “global” state - state that is needed across many parts of your application.
Como instalar redux en un proyecto
yarn add redux react-redux
Después de importar redux, creamos un ___ valido porque se necesita obligatorio en el store, aunque este vacío
reducer
Luego en el index.js se importa ____ de redux y ___ de react-redux
createStore y Provide
Que se le debe pasar a createStore?
const store = createStore( reducers,
// all reducers go here
{}
//initial state );
Ahora metemos nuestro en el ____ y le mandamos el store
Provider
What is Flux?
architecture that complements React and the concept of Unidirectional Data Flow.
Los datos viajan unidirreccional, teniendo un unico camino, y un sitio donde se almacena el estado
What is Redux DevTools?
Redux DevTools is a live-editing time travel environment for redux with hot reloading, action replay, and customizable UI.
How to add multiple middlewares to Redux?
You can use applyMiddleware where you can pass each piece of middleware as a new argument. So you just need to pass each piece of middleware you’d like. For example, you can add Redux Thunk and logger middlewares as an argument as below,