I'm writing a React app, namely a navbar. I have a logo and navItems there. Logo display and color of the navbar background are conditional. Added Aibnb guide to esLint, now my navbar code looks like this:
class Toolbar extends Component {
handleClick = () => {
this.props.history.push('/');
}
render() {
const { color, showLogo } = this.props;
return (
<header
style={{
backgroundColor: color,
}}
className={classes.Toolbar}
>
<Logo click={this.handleClick} show={showLogo} />
<NavItems />
</header>
);
}
}
Toolbar.propTypes = {
color: PropTypes.string.isRequired,
showLogo: PropTypes.string.isRequired,
};
export default withRouter(Toolbar);
and I get the following eslint errors:
(line 11) is
this.props.history.push('/');
How do I transform this method to make the code compile and work without errors?
(Tried to rewrite it in as a destructing props assignment, got an error like cannot get 'push' of undefined)