gpt4 book ai didi

javascript - 内部函数如何知道这个参数?

转载 作者:行者123 更新时间:2023-12-01 03:49:08 24 4
gpt4 key购买 nike

我正在学习 Redux-Thunk,我有一个关于 JavaScript 的一般问题。

我们如何获得调度函数?

function incrementAsync() {
return dispatch => {
setTimeout(() => {
// Yay! Can invoke sync or async actions with `dispatch`
dispatch(increment());
}, 1000);
};
}

它是像 incementAsync()(dispatch) 一样传递还是来自外部函数?

代码示例来自https://github.com/gaearon/redux-thunk

最佳答案

The inner function receives the store methods dispatch and getState as parameters.

您的函数将被 incementAsync()(dispatch, getState) 这样的库使用

你不需要这样做。

关于javascript - 内部函数如何知道这个参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43363120/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com