链式箭头函数语法 [英] Chained Arrow function syntax
本文介绍了链式箭头函数语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
const fetch = url => dispatch => {
// ...
}
export const fetchQuestions = tag => (dispatch) => {
return dispatch(fetch(tag));
};
<$ c中的 dispatch
是什么$ c>获取功能? url
是第一个和单个参数 fetch
函数。但这里的派遣
是什么?
What is dispatch
in the fetch
function ? url
is a first and single parameter fetch
function. But what is dispatch
here ?
推荐答案
这相当于一个功能回到另一个。即这个
This is equivalent to one function returning another. I.e. this
const fetch = url => dispatch => {
// ...
}
相当于
const fetch = function(url) {
return function(dispatch) {
// ...
}
}
同样如此
Similarly this
export const fetchQuestions = tag => (dispatch) => {
return dispatch(fetch(tag));
};
相当于
export const fetchQuestions = function(tag) {
return function(dispatch) {
return dispatch(fetch(tag));
}
};
这篇关于链式箭头函数语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文