gpt4 book ai didi

javascript - 为什么我总是收到 "TypeError: callback is not a function"

转载 作者:行者123 更新时间:2023-12-04 10:23:43 25 4
gpt4 key购买 nike

React 中的简单问题,我只想做一个简单的回调来延迟数据的加载

function getSettings(callback) {
getColors();
callback();
}

useEffect(() => {
getSettings().console.log(settings);
// eslint-disable-next-line
}, []);

我得到:
"TypeError: callback is not a function"

最佳答案

看起来您没有将回调传递给 getSettings()。如果你想通过 console.log,你可以尝试:

getSettings(() => console.log(settings));    

关于javascript - 为什么我总是收到 "TypeError: callback is not a function",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60721035/

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