DEV Community

Discussion on: Hide menu when scrolling in React.js

Collapse
 
nickcrews profile image
Nick Crews

This is great! One tiny improvement, to get rid of the classnames dependency, you could use string formatting, e.g.

className={`navbar${this.state.visible ? "" : " navbar--hidden" }`}
Enter fullscreen mode Exit fullscreen mode

Related but separate question: I have this implemented and it's working great, but the top of the main content is chopped off by the navbar when scrolled to the top of the page. The main content needs to be bumped down by the height of the navbar. Is there a good way to do this?