54
rated 0 times
[
59]
[
5]
/ answers: 1 / hits: 20233
/ 6 Years ago, fri, july 20, 2018, 12:00:00
Using React Router 4.2
My attempt is to open a new tab upon clicking on a navigation link and at the same time be redirected to the site homepage.
ie: Navigation bar: clicking on Policies
Even though the code bellow behaves as the requirements above: Is this the advisable way to go about it?
Aiming to learn best practices here on Routes.js.
//Routes.js
import HandbookDoc from './policies.pdf'
...
<Route
path=/registration/policies
component={() => window.open(`${HandbookDoc}`,'_blank').then(window.location= '/')}
/>
....
//Navigation.js (using react-router-bootstrap)
<NavDropdown eventKey={3} id=formId title=Registration>
<LinkContainer to=/registration/financial-aid>
<MenuItem eventKey={3.1}>Financial Aid</MenuItem>
</LinkContainer>
<LinkContainer to=/registration/policies>
<MenuItem eventKey={3.2}>Policies</MenuItem>
</LinkContainer>
</NavDropdown>
More From » reactjs