저는 Redux-Form을 사용하고 있습니다. (Redux-Form 사이트의 동기화 유효성 검증 예제에서와 같이) <Field>
함수를 사용하여 렌더링 된 구성 요소를 사용하고 있습니다 : http://redux-form.com/6.0.0-rc.1/examples/syncValidation/.Typescript에서 Redux-Form 사용 WrappedFieldProps <S> 인터페이스를 사용하고 싶습니다. 그러나 내보낼 수 없습니다. 내가 잘못하고 있니?
Typescript를 사용할 때 renderField
함수의 매개 변수를 입력하고 싶습니다. 매개 변수의 유형은 인터페이스 WrappedFieldProps<S>
을 기반으로하지만 인터페이스를 내보낼 수 없으므로 사용할 수 없습니다.
그래서 WrappedFieldProps< S>
을 사용하고 싶거나 더 좋은 방법이 있습니까?
예제 코드 :
interface RenderFieldProps extends WrappedFieldProps<AppState> {
placeholder: string,
type: string,
};
public render(): JSX.Element {
return (
<form onSubmit={this.props.handleSubmit(this.handleFormSubmit)}>
<Field name="email" component={this.renderField} type="text" placeholder="Add your email address"/>
<button type="submit">Submit form</button>
</form>
);
}
private renderField = (props: RenderFieldProps) => (
<div>
<input {...props.input} placeholder={props.placeholder} type={props.type}/>
</div>
);