Operaciones asincrónicas con redux-thunk
# npm
npm install --save redux-thunk
# yarn
yarn add redux-thunkimport { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
// ...
const store = createStore(
reducer,
applyMiddleware(thunk)
);const newTask = task => {
return dispatch => {
return axios.post("...", task)
.then(response => {
dispatch({
type: "NEW_TASK",
task: response
});
});
};
};Last updated