constructor (props) {
super(props);
this.toggleMenu = this.toggleMenu.bind(this);
this.showSidebar = this.showSidebar.bind(this);
this.resize = this.resize.bind(this);
this.toggleMenuByClick = this.toggleMenuByClick.bind(this);
this.showSidebarByClick = this.showSidebarByClick.bind(this);
this.state = {
toggleMenu: false,
showSidebar: false,
height: 'auto'
};
}
class MyClass {
foo = () => {
console.log('foo a = ', this.a);
}
bar = () => {
this.a = 10;
setTimeout(this.foo, 10); // Мы не биндим foo на this
}
}
const o = new MyClass();
const bar = o.bar; // и тут тоже не биндим
bar(); // выводит "foo a = 10"
onMouseMoveHandler = (e) => {
if (this.state.active) {
....