const fetch = url => dispatch => {
// ...
}
export const fetchQuestions = tag => (dispatch) => {
return dispatch(fetch(tag));
};
What
Its a shorter way of writing a function that returns another function
. The arguments url
and dispatch
are arguments to the curryed function The ES5 equivalent of arrow function syntax would be
function fetch(url) {
return function(dispatch) {
....
}
}
or with Arrow syntax as
const fetch = (url) => {
return (dispatch) => {
// ...
}
}
Similarly you would have fetchQuestion
written as
export function fetchQuestions(tag) {
return function(dispatch){
return dispatch(fetch(tag));
}
}
or with Arrow syntax as
export const fetchQuestions = (tag) => {
return (dispatch) => {
return dispatch(fetch(tag));
}
};