So I have a single page where I want to click a button that scrolls to a specific part of the page. I am using react router and when I click on the button it just replaces the section I want with the first page. Anyone knows why is it doing that? My code is located below:
const [scrollNav, setScrollNav] = React.useState(false)
return (
<>
<Nav>
<NavbarContainer>
<Router>
<NavMenu>
<NavLinks
> About </NavLinks>
<Link to="/Experience"
>Experience</Link>
<NavLinks>Resume</NavLinks>
<NavLinks to="/Contact" > Contact</NavLinks>
<Switch>
<Router path='/Experience'>
<Experience/>
</Router>
</Switch>
</NavMenu>
</Router>
<MobileIcon onClick = {toggle}>
<FaBars/>
</MobileIcon>
</NavbarContainer>
</Nav>
</>
)
}
export default Navbar;```