首页 > 解决方案 > 为什么 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,
    };
}

我不明白出了什么问题。我在那里看不到任何承诺。

标签: typescripteslintredux-form

解决方案


redux-form 本身依赖于 promise 调用。所以返回 change 或 getFormValues 将使它成为一个 promise 返回函数。


推荐阅读