All:
I am pretty new to Redux, when I try to follow the tutorial about async action http://redux.js.org/docs/advanced/AsyncActions.html
There is a concept called thunk, I do not quite get the idea why we need a thunk to do async action, why we can not just simply dispatch init signal, then fetch data then dispatch finish signal in the promise from fetch data?
function fetchDataAction(dispatch){
dispatch({
type: "START"
})
fetch("DATA_URL")
.then(function(res){return res.json();})
.then(function(json){
dispatch({
type: "SUCCESS",
data: json
})
})
}
Thanks
redux-thunk
middleware. – Mario Tacke