Redux格式的文件类型错误:类型“ Props”缺少以下属性:字段,元

时间:2019-11-13 03:40:56

标签: reactjs typescript redux-form

使用字段类型时出现错误,我使用WrappedFieldArrayProps定义道具,但ts检查错误类型'InjectedFormProps <{},{},字符串>和{子代?:ReactNode; }”缺少“道具”类型的以下属性:字段,元。

这是我的代码

import React from 'react';
import { Field, reduxForm, InjectedFormProps,  WrappedFieldArrayProps} from 'redux-form';
import { Form, FieldGroup } from '~/lamb';
import AlertRuleForm from './form_rule';
import AlertEmailForm from './form_email';
import t from '~/locale';
import FormFooter from '../FormFooter';
import { compose } from 'redux';

interface Props extends InjectedFormProps, WrappedFieldArrayProps {}

const connector = compose(
  reduxForm({
    form: 'AlertForm',
  }),
);

const UpdateAlertGroupForm = (props: Props) => {
    const { fields, handleSubmit, error } = props;
    return (
      <div>
        <Form horizontal onSubmit={handleSubmit} formError={error}>
          {fields.getAll().includes('name') && (
            <Field
              component={FieldGroup}
              name="name"
              type="text"
              label="alert_name"
              placeholder="Please input alert name"
              required
            />
          )}
          {fields.getAll().includes('alertRules') && <AlertRuleForm />}
          {fields.getAll().includes('emailGroupIds') && <AlertEmailForm />}
          <FormFooter {...props} />
        </Form>
      </div>
    );
};

export default connector(UpdateAlertGroupForm) // error from here;

错误

类型'(props:Props)=>元素的参数不能分配给类型'ComponentType>'的参数。   类型'(props:Props)=>元素'不能分配给'FunctionComponent>'类型。     参数“ props”和“ props”的类型不兼容。       输入'InjectedFormProps <{},{},string>和{children ?: ReactNode; }”缺少类型“ Props”的以下属性:fields,metats(2345)

1 个答案:

答案 0 :(得分:0)

interface Props extends Partial<InjectedFormProps>, WrappedFieldArrayProps {}