我创建了自定义状态较少的组件,以使用redux形式的文本区域。我正在使用打字稿管理道具,但在自定义组件的redux-form字段中收到打字稿错误。
版本:
redux-form: ^8.1.0
@types/redux-form: ^7.4.13
我遇到以下错误:
Type 'FunctionComponent<WrappedFieldProps & IFieldOptions>' is not assignable to type '("input" & FunctionComponent<WrappedFieldProps & IFieldOptions>) | ("select" & FunctionComponent<WrappedFieldProps & IFieldOptions>) | ("textarea" & FunctionComponent<WrappedFieldProps & IFieldOptions>) | (ComponentClass<...> & FunctionComponent<...>) | (FunctionComponent<...> & FunctionComponent<...>)'.
Type 'FunctionComponent<WrappedFieldProps & IFieldOptions>' is not assignable to type '"input" & FunctionComponent<WrappedFieldProps & IFieldOptions>'.
Type 'FunctionComponent<WrappedFieldProps & IFieldOptions>' is not assignable to type '"input"'
文本区域组件:
export const RenderTextArea: React.SFC<WrappedFieldProps & IFieldOptions> = (props) => {
const { disabled, input, label, meta, name, placeholder, type, textareaProps } = props;
return (
<Form.Field>
<label>{label}</label>
<TextArea
name={name} placeholder={placeholder} type={type} {...input} {...textareaProps}
disabled={disabled}
/>
{meta.touched && meta.error ? <span className='error'>{meta.error}</span> : ''}
</Form.Field>
)}
Redux表单字段:
<Field
name='description'
placeholder='description'
component={RenderTextArea}
textareaProps={textareaProps}
/>