在Javascript中,从一个箭头函数到另一个箭头函数意味着什么?
在以下功能中,调度来自何处,控制流程是什么在Javascript中,从一个箭头函数到另一个箭头函数意味着什么?,javascript,reactjs,react-redux,redux-thunk,Javascript,Reactjs,React Redux,Redux Thunk,在以下功能中,调度来自何处,控制流程是什么 export const getContacts = () => async (dispatch) => { const res = await axios.get("http://jsonplaceholder.typicode.com/users"); dispatch({ type: GET_CONTACTS, payload: res.data, }); }; 我了解基本的arrow函数,但调用getC
export const getContacts = () => async (dispatch) => {
const res = await axios.get("http://jsonplaceholder.typicode.com/users");
dispatch({
type: GET_CONTACTS,
payload: res.data,
});
};
我了解基本的arrow函数,但调用getContacts()时实际会发生什么。既然我没有传递任何信息,那么调度从何而来?这是从thunk来的吗?我没有将thunk导入此文件,这就是我感到困惑的原因。这是整个文件:
import { GET_CONTACTS, ADD_CONTACT, DELETE_CONTACT } from "./types";
import axios from "axios";
// the following returns the objects that we want to push to the dispatch in contactRedcuer
export const getContacts = () => async (dispatch) => {
const res = await axios.get("http://jsonplaceholder.typicode.com/users");
dispatch({
type: GET_CONTACTS,
payload: res.data,
});
};
在Javascript中,从一个箭头函数到另一个箭头函数意味着什么
第一个箭头函数将第二个箭头函数作为返回值
如果不将参数传递给第一个参数(如本例所示)以形成闭包,那么这通常不是一件有用的事情
我了解基本的arrow函数,但调用getContacts()时实际会发生什么。既然我没有传递任何信息,那么调度从何而来
dispatch
在调用返回函数时出现,这在您共享的代码中不会发生
const first=(参数到第一个)=>
(参数到秒)=>console.log({
先从一个论点到另一个论点,
论点_到_秒
});
常数秒=第一(“你好”);
第二(“再见”)代码>