“Redux Thunk” Código de respuesta

Redux Thunk

npm i --save redux react-redux redux-thunk // You will need these redux packages
DecodeBuzzing

¿Qué es Redux Thunk?


Redux Thunk is middleware that allows you to return functions,
rather than just actions, within Redux. 
This allows for delayed actions, including working with promises.

---
One of the main use cases for this middleware is 
for handling actions that might not be synchronous, 
for example, using axios to send a GET request. 
Redux Thunk allows us to dispatch those actions asynchronously 
and resolve each promise that gets returned.
KostasX

React Redux Thunk

import { createStore, applyMiddleware, compose } from "redux";
import rootReducer from "../reducers/index";
import { forbiddenWordsMiddleware } from "../middleware";
import thunk from "redux-thunk";

const storeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

const store = createStore(
  rootReducer,
  storeEnhancers(applyMiddleware(forbiddenWordsMiddleware, thunk))
);

export default store;
Wild Weevil

Respuestas similares a “Redux Thunk”

Preguntas similares a “Redux Thunk”

Más respuestas relacionadas con “Redux Thunk” en JavaScript

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código