We have a on our React application, and we are attempting to nest several <NavDropdown.Item /> within a <NavDropdown />.
In the screenshot above, clicking Tools routes to /tools, and clicking the dropdown options should link to /tools/shot-charts, /tools/team-stats-graphs, etc. You can see this in the code below:
import { Nav, Navbar, NavDropdown } from 'react-bootstrap';
<Navbar.Collapse id='basic-navbar-nav'>
<div className='navbar-nav-wrapper'>
<Nav>
<NavDropdown
title='Tools'
as={Link}
to='/tools'
className={`${isTools ? 'selected' : ''}`}
onMouseEnter={() => setIsToolsHovered(true)}
onMouseLeave={() => setIsToolsHovered(false)}
onClick={() => history.push('/tools')}
show={isToolsHovered}
>
<NavDropdown.Item as={Link} to={'/tools/shot-charts'}>Shot Charts</NavDropdown.Item>
<NavDropdown.Item as={Link} to={'/tools/team-scatter'}>Team Stats Graphs</NavDropdown.Item>
<NavDropdown.Item as={Link} to={'/tools/player-scatter'}>Player Stats Graphs</NavDropdown.Item>
<NavDropdown.Item as={Link} to={'/tools/model-fitting'}>Linear Regressions</NavDropdown.Item>
</NavDropdown>
</Nav>
</div>
</Navbar.Collapse>
Currently when Shot Charts is clicked, the page renders twice, first with the /tools/shot-charts url and then immediately after to the /tools url. This is problem. It appears that onClick={() => history.push('/tools')} on the <NavDropdown /> is triggering even though Shot Charts is clicked rather than Tools.
If we remove onClick={() => history.push('/tools')}, then the 4 dropdown buttons work, however clicking on Tools then does not change the page. It looks like as={Link} and to='/tools' on the <NavDropdown /> aren't doing anything to make Tools clickable.
Is there anyway for the and the <NavDropdown.Item /.'s to be separate links as is described & coded above?
