reactjs - Redux Form Typescript Pass Custom Props -




i trying pass custom props component decorated reduxform. new in typescript.

the first problem can't wrap decorated component connect:

export default     connect(mapstatetoprops)(         reduxform({             form: 'myform'         })(mycomponent)     ) 

the error:

error:(89, 5) ts2345:argument of type 'decoratedcomponentclass<any, partial<configprops<any, {}>>>' not assignable parameter of type 'componenttype<{ addressvalue: any; isdeliveryaddress: any; customertypevalue: any; } & dispatchpr...'. type 'decoratedcomponentclass<any, partial<configprops<any, {}>>>' not assignable type 'statelesscomponent<{ addressvalue: any; isdeliveryaddress: any; customertypevalue: any; } & dispa...'. type 'decoratedcomponentclass<any, partial<configprops<any, {}>>>' provides no match signature '(props: { addressvalue: any; isdeliveryaddress: any; customertypevalue: any; } & dispatchprop<any> & { children?: reactnode; }, context?: any): reactelement<any> | null'. 

it's caused wrong types said new in typescript , not sure how deal these long errors. @ moment don't need pass props validate form function helpful future tasks.

the main problem can't pass custom props decorated component:

export default reduxform({     form: 'myform' })(     connect(mapstatetoprops)(mycomponent) ); 

the form props:

interface props extends injectedformprops {     onsubmit: () => void;     // values state     loading: boolean; // custom prop } 

and when try this:

<myform loading onsubmit={this.handlesubmit} /> 

it throws error:

error:(134, 25) ts2339:property 'loading' not exist on type 'intrinsicattributes & intrinsicclassattributes<forminstance<any, partial<configprops<any, {}>>>> ...'. 

the strange part able pass props declared in injectedformprops interface can't pass custom props. actually, able pass props mapstatetoprops function. maybe can't pass custom props decorated component reduxform.

here have example how define custom props:

import { formprops, reduxform } "redux-form";  interface initialvaluesprops {   name: string; }  interface customformprops extends formprops<initialvaluesprops, {}, {}> {   loading: boolean; }  class customform extends react.component<customformprops> {    render() {       const loading = this.props.loading        const name = this.props.initialvalues.name;    } }  export default reduxform({ form: 'myform' })(customform) 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -