Answers for "react bootstrap hide toggle menu when scrolling down"

0

react bootstrap hide toggle menu when scrolling down

import React, { Component } from 'react';

   class App extends Component {

   constructor(props) {
    super(props);

      this.state = {  scrollBackground: 'nav-bg' };
      this.handleScroll = this.handleScroll.bind(this);
   }


   handleScroll(){
      this.setState ({
         scrollBackground: !this.state.scrollBackground
       })
    }

 render() {
 const scrollBg = this.scrollBackground ? 'nav-bg scrolling' : 'nav-bg';

 return (
   <div>

       <Navbar inverse toggleable className={this.state.scrollBackground} 
                                  onScroll={this.handleScroll}>
        ...
      </Navbar>

    </div>
   );
  }
}

export default App;
Posted by: Guest on July-09-2020

Code answers related to "react bootstrap hide toggle menu when scrolling down"

Code answers related to "Javascript"

Browse Popular Code Answers by Language