小编lom*_*ans的帖子

React useState hooks 错误:“xxx”类型的参数不可分配给“SetStateAction<xx>”类型的参数

我使用 react hooks 来更新,但是在 setState 时会注意到错误。

'{ alertRules: any; 类型的参数 }' 不能分配给'SetStateAction' 类型的参数。对象字面量只能指定已知属性,并且类型“SetStateAction”中不存在“alertRules”.ts(2345)

这是我的代码。

import React, { useState, useEffect } from 'react';
import { FieldArray } from 'redux-form';
import { CoordinateSelect } from '~/fields';
import lodash from 'lodash';
import { connect } from 'react-redux';
import { filterDispatchers } from '~/actions';
import t from '~/locale';

interface Props {
  getAlertRules(o: object): Promise<any>;
}
type Alert = {
  ...
}

const connector = connect(
  null,
  filterDispatchers('getAlertRules'),
);

const AlertRuleForm = (props: Props) => …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs tsx react-hooks

11
推荐指数
1
解决办法
1万
查看次数

标签 统计

react-hooks ×1

reactjs ×1

tsx ×1

typescript ×1