1

Getting this error in onSubmit() function.

enter image description here

this is not accessible within onSubmit() function. I have also added this.onSubmit = this.onSubmit.bind(this); but still it is not working.

Code :

...
class CamapaignNew extends Component {

    constructor(props) {
        super(props);
        this.state = {minimumContribution : ''};
        this.onSubmit = this.onSubmit.bind(this)
    }
    onSubmit = async (event) => {
        event.preventDefault();
        const accounts = await web3.eth.getAccounts();
        console.log(this);
        const minC = this.state.minimumContribution;
        await factory.methods.createCampaign(minC).send({
            from: accounts[0]
        });

    }
    render() {
        return (
            ...
                <Form onSubmit={this.onSubmit}>
                    <Form.Field>
                        <label>Minimum Contribution</label>
                        <Input 
                            label="wei" 
                            labelPosition='right' 
                            value={this.state.minimumContribution}
                            onChange={(event) => {this.setState({ minimumContribution: event.target.value })}}
                        />
                    </Form.Field>
                    <Button primary>Create!</Button>
                </Form>
           ...
    }
}

Thank you in advance.

4

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.