原代碼:
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)));
}
}
雙箭頭意思是導出一個函數