es6中的雙箭頭函數

原代碼:函數

const fetchPosts = subreddit => dispatch => {fetch

dispatch(requestPosts(subreddit));

    return common.fetch({url: config.argumentSubmit, method: 'POST'})

    .then(response => response.message)

    .then(message => dispatch(receivePosts(subreddit, message)));

};url

解析爲:spa

const fetchPosts = function (subreddit) {code

return function (dispatch) {

            return  common.fetch({url: config.argumentSubmit, method: 'POST'})

                       .then(response => response.message)

                        .then(message => dispatch(receivePosts(subreddit, message)));
            }

}it

雙箭頭意思是導出一個函數io

相關文章
相關標籤/搜索