es6中的双箭头函数

原代码:

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)));
            }

}

双箭头意思是导出一个函数

原文地址:https://www.cnblogs.com/cn-andy/p/9493307.html