typescript - 为什么 mapStateToProps 有 Eslint 警告“返回承诺的函数必须是异步的”?
问题描述
我收到了 Eslint 警告:
Functions that return promises must be async.
eslint(@typescript-eslint/promise-function-async)
开启功能:
import { getFormValues, change } from 'redux-form';
function mapStateToProps(state: any, ownProps: IWizardPageProps) {
const stateProps = getFormValues('wizard')(state);
return {
...ownProps,
...stateProps,
change,
};
}
我不明白出了什么问题。我在那里看不到任何承诺。
解决方案
redux-form 本身依赖于 promise 调用。所以返回 change 或 getFormValues 将使它成为一个 promise 返回函数。
推荐阅读
- python - Python Selenium - 禁用镀铬标签睡眠/休眠
- pandas - Pandas 中的重复测量方差分析,不同列中的因变量值
- scala - 带有 Spylon-Kernel 的 Jupyter 中 spark.implicits._ 的问题
- python - 如何从图像中删除相邻的重复像素?
- sql - 对行进行分组,同时排除特定列上的空值并聚合另一个
- typescript - TypeScript:如何初始化依赖于 T 的通用类的成员?
- typo3 - TYPO3 10.4.12 optionSplit in IMAGE srcset
- r - 循环数据框的列
- c - 错误:C + 多线程中通过 TCP 套接字传输文件的 Seg 错误
- reactjs - 如何在 useEffect() 中进行查询以避免 InvalidHookError?