简体   繁体   English

为什么mapStateToProps会发出Eslint警告“返回承诺的函数必须异步”?

[英]Why mapStateToProps has Eslint warning 'Functions that return promises must be async'?

I got Eslint warnings: 我收到了Eslint警告:

Functions that return promises must be async.
eslint(@typescript-eslint/promise-function-async)

On function: 开启功能:

import { getFormValues, change } from 'redux-form';

function mapStateToProps(state: any, ownProps: IWizardPageProps) {
    const stateProps = getFormValues('wizard')(state);
    return {
        ...ownProps,
        ...stateProps,
        change,
    };
}

I don't understand what is wrong. 我不明白怎么了。 I don't see any promise there. 我在那里看不到任何承诺。

The redux-form itself relies on the promise call. redux表单本身依赖于promise调用。 So returning change or getFormValues will make it a promise returning functions. 因此,返回change或getFormValues将使其成为一个承诺返回函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 什么 JS 错误有助于防止 typescript 错误返回承诺的函数必须是异步的 @typescript-eslint/promise-function-async - What JS error help prevent with typescript error when it is Functions that return promises must be async @typescript-eslint/promise-function-async 返回未等待承诺的异步函数的返回类型 - Return type of async functions which return un-awaited promises ESLint:如何在函数上找到不必要的“异步”标记? - ESLint: How to find unnecessary “async” markers on functions? Eslint 对 getter 缺少返回类型发出警告 - Eslint throws warning on missing return type for getter eslint - 异步箭头 function 返回值错误 - eslint - async arrow function return value error 为什么异步功能中没有“ then” - Why there's no “then” in async functions ESLint 发布 no-misused-promises,其中匿名函数用于等待多个异步调用 - ESLint issues no-misused-promises where anonymous function used to await multiple async calls 异步 function 作为 prop 传递给 React 组件,导致 @typescript-eslint/no-misused-promises 错误 - Async function passed as prop into React component causing @typescript-eslint/no-misused-promises error Firebase函数tslint错误必须正确处理Promise - Firebase functions tslint error Promises must be handled appropriately 打字稿 | 关于缺少函数返回类型的警告,ESLint - Typescript | Warning about Missing Return Type of function, ESLint
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM