Slide 20
Slide 20 text
redux-thunk ⭐2392
Executes the func,on with dispatch and getState as
arguments if an Action is a func,on (thunk)
const fetchBeers = () => (dispatch, getState) => {
return fetch('/beers')
.then(res => res.json())
.then(items => dispatch('FETCH_BEERS_SUCCEEDED', items))
.catch(error => dispatch('FETCH_BEERS_FAILED', error));
};
dispatch(fetchBeers());