score:8

Accepted answer

you will need to bind those functions to the context of the component. inside constructor you will need to do this:

export default class logincard extends react.component {
    constructor(props) {
        super(props);
        this.handleloginbtnclicked = this.handleloginbtnclicked.bind(this);
        this.checkinputvalidation = this.checkinputvalidation.bind(this);
    }

    //this is the method handleloginbtnclicked
    handleloginbtnclicked() {
        ...
    }

    //this is the method checkinputvalidation 
    checkinputvalidation() {
        ...
    }

    ...
    ..
    .
}

score:2

where are you binding the handleloginbtnclicked? you may be losing the functions context and losing the meaning of the special variable this. react will handle and trigger the onclick event, calling the function from a different context which is why it has been lost.

you should use the following syntax to create a new bound function to add as the event listener for the onclick event. this will ensure that handleloginbtnclicked's context is not lost.

<element onclick={this.handleloginbtnclicked.bind(this)}>

Related Query

More Query from same tag