原代码:
const fetchPosts = subreddit => dispatch => {
dispatch(requestPosts(subreddit));
return common.fetch({url: config.argumentSubmit, method: 'POST'})
.then(response => response.message)
.then(message => dispatch(receivePosts(subreddit, message)));
};
解析为:
const fetchPosts = function (subreddit) {
return function (dispatch) {
return common.fetch({url: config.argumentSubmit, method: 'POST'})
.then(response => response.message)
.then(message => dispatch(receivePosts(subreddit, message)));
}
}
双箭头意思是导出一个函数