Why is someFunction
not being fired in the following snippet? I get an error: someFunction is not a function
.
class MyComponent extends React.Component {
constructor(props) {
super(props);
this.setInterval = this.setInterval.bind(this);
this.someFunction = this.someFunction.bind(this);
}
setInterval = () => {
console.log('Set Interval');
setTimeout(function () {
this.someFunction()
}, 2000);
}
someFunction = () => {
console.log('Some function');
}
componentDidMount() {
this.timer = this.setInterval();
}
}