I am new to reactJs and I am having an issue with undefined function.
As I see I define it at my constructor, but..
bundle.js:758 Uncaught ReferenceError: myCallback is not defined.
import React from "react";
import ReactDOM from "react-dom";
import Vivus from "vivus";
export default class MySkills extends React.Component {
constructor() {
super();
this.state = {visable: false};
this.onScroll = this.onScroll.bind(this);
this.myCallback = this.myCallback.bind(this);
}
componentDidMount() {
document.addEventListener('scroll', this.onScroll);
}
myCallback() {
alert("myCallback");
}
onScroll() {
var scrollY = window.scrollY;
if (scrollY > 2300 && this.state.visable === false) {
new Vivus("foo", {duration: 100, file: 'bar'}, myCallback.bind(this));
}
}
Maybe somebody can explain better the binding of functions? It seems to be working with the onScrool function, but the myCallback function is not working.
Thank You!