From 3a1fb5634bf0a573bdc4395905bdeb11a8d7ba6a Mon Sep 17 00:00:00 2001 From: Manu Date: Tue, 18 Jun 2019 16:04:08 +0300 Subject: [PATCH] bug --- src/components/Header/Header.jsx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/components/Header/Header.jsx b/src/components/Header/Header.jsx index 60a3f8145..842ca17b9 100644 --- a/src/components/Header/Header.jsx +++ b/src/components/Header/Header.jsx @@ -22,18 +22,11 @@ class Header extends React.Component { this.state = { mobileOpen: false }; - this.handleDrawerToggle = this.handleDrawerToggle.bind(this); - this.headerColorChange = this.headerColorChange.bind(this); } - handleDrawerToggle() { + handleDrawerToggle = () => { this.setState({ mobileOpen: !this.state.mobileOpen }); } - componentDidMount() { - if (this.props.changeColorOnScroll) { - window.addEventListener("scroll", this.headerColorChange); - } - } - headerColorChange() { + headerColorChange = () => { const { classes, color, changeColorOnScroll } = this.props; const windowsScrollTop = window.pageYOffset; if (windowsScrollTop > changeColorOnScroll.height) { @@ -52,6 +45,11 @@ class Header extends React.Component { .classList.remove(classes[changeColorOnScroll.color]); } } + componentDidMount() { + if (this.props.changeColorOnScroll) { + window.addEventListener("scroll", this.headerColorChange); + } + } componentWillUnmount() { if (this.props.changeColorOnScroll) { window.removeEventListener("scroll", this.headerColorChange); @@ -100,7 +98,7 @@ class Header extends React.Component { - +