TS2339: Property does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<FormInstance<{}, Partial<ConfigProps<{}, {}>>>> & ...'

Viewed 3350

I am new to typescript and redux and I'm trying to work through the SimpleForm example from redux-form.

I have the following form component

import * as React from 'react';
import {Field, reduxForm} from 'redux-form';

class SimpleForm extends React.Component<any, any> {

public render() {

    const { handleSubmit, doCancel } = this.props;

    return (
        <div>
            <h1>Simple Form</h1>

            <form onSubmit={handleSubmit}>
                <div>

                <label htmlFor="firstName">First Name</label>
                <Field name="firstName" component="input" type="text" />

                <label htmlFor="lastName">Last Name</label>
                <Field name="lastName" component="input" type="text" />

                </div>
                <div>
                    <button type="button" onClick={doCancel}>Cancel</button>
                    <button type="submit">Submit</button>
                </div>


            </form>

        </div>
)};

}
export default reduxForm({ form: "simpleForm" })(SimpleForm);

And I consume the component using

return (
        <div>
            <SimpleForm onSubmit={this.handleSubmit} doCancel={this.doCancel} />

        </div>
    );`

This gives me the following error

    TS2339: Property 'doCancel' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<FormInstance<{}, Partial<ConfigProps<{}, {}>>>> & ...'.

if I remove the doCancel prop the form renders ok, but obviously the cancel button is non-functional.

What am I doing wrong here ?

1 Answers
Related