give multiple path names in to react navlink react router dom code example
Example 1: multiple path name for same navlink
import React from 'react';
import { useLocation } from 'react-router-dom';
export default () => {
const { pathname } = useLocation();
return (
<li className='Navigation__list-item'>
<NavLink
to="/events"
isActive={() => ['/events', '/myevents'].includes(pathname)} >
Events
</NavLink>
</li>
);
};
Example 2: multiple path names for a same component in react router
<Router>
{["/home", "/users", "/widgets"].map((path, index) =>
<Route path={path} component={Home} key={index} />
)}
</Router>