I have a .js file as such:
My Class Component:
[...]
constructor(props, context) {
[...]
this.method1 = this.method1.bind(this);
}
anotherMethod() {
[...]
this.state.method1();
}
method1() {
//Do something
}
I am getting this error: _this3.state.method1 is not a function. I tried following some other known solutions in here.
I have a few questions:
- What is the root cause?
- What is _this3 an where did it come from?
Thanks.
EDIT: I found the solution which is to remove the "state". Instead of this.state.method1()
, it should be this.method1()
. Just curious how come i do not need the "state" when i bind it above?