I am trying to pass custom details to my component that is decorated reduxForm. I am also very new to Typescript.
The first problem is that I cannot wrap the decorated component with a connection:
export default
connect(mapStateToProps)(
reduxForm({
form: 'myform'
})(MyComponent)
)
Error:
Error:(89, 5) TS2345:Argument of type 'DecoratedComponentClass<any, Partial<ConfigProps<any, {}>>>' is not assignable to parameter of type 'ComponentType<{ addressValue: any; isDeliveryAddress: any; customerTypeValue: any; } & DispatchPr...'.
Type 'DecoratedComponentClass<any, Partial<ConfigProps<any, {}>>>' is not assignable to type 'StatelessComponent<{ addressValue: any; isDeliveryAddress: any; customerTypeValue: any; } & Dispa...'.
Type 'DecoratedComponentClass<any, Partial<ConfigProps<any, {}>>>' provides no match for the signature '(props: { addressValue: any; isDeliveryAddress: any; customerTypeValue: any; } & DispatchProp<any> & { children?: ReactNode; }, context?: any): ReactElement<any> | null'.
This is clearly caused by the wrong types, but, as I said, I'm new to Typescript, and I'm not sure how to handle these long errors. At this point, I do not need to pass any support to the form function validate, but it will be very useful for future tasks.
The main problem is that I cannot pass the user details to the decorated component:
export default reduxForm({
form: 'myform'
})(
connect(mapStateToProps)(MyComponent)
);
props of the form:
interface Props extends InjectedFormProps {
onSubmit: () => void;
loading: boolean;
}
and when I try this:
<MyForm loading onSubmit={this.handleSubmit} />
it gives one more error:
Error:(134, 25) TS2339:Property 'loading' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<FormInstance<any, Partial<ConfigProps<any, {}>>>> ...'.
, , InjectedFormProps, - . , mapStateToProps. , - reduxForm.