(react-scroll) Not working when ScrollLink & ScrollElement are different component

Viewed 179

I have route.js component, in which I Import navbar.js component & homePage.js component. When I click on navbar menu , I want to go to specific section of homePage.js component.

Example, when I click on AboutMe menu then AboutMe section of homePage come. I try to follow

How to scroll to a specific targeted component when clicking on Navbar Link

this stack overflow link but it's not work, according to this answer when I wrap my link to ScrollLink, menu will not display.

Please help me I am new in reactjs.

render() {
  if (this.state.redirect) {
    return (
      <Router>
        <DIV className="template-nav">
          <NavBar
            menu={this.menu}
            onClick={()=>this.changeRedirect()}
          ></NavBar>
        </DIV>
        <Redirect from="*" to="/" />
        <Route
          exact
          path="/"
          component={HomePage}
          navBar_menu={this.navBar_menu}
        />
      </Router>
    );
  }
  return (
    <Router>
      <DIV className="template-nav">
        <NavBar menu={this.menu}></NavBar>
      </DIV>
    </Router>
  );
}
0 Answers
Related