Answers for "multiple path name for same navlink"

0

multiple path name for same navlink

import React from 'react';
import { useLocation } from 'react-router-dom';

// Active the Link on two URLs

export default () => {
	
    // extract pathname from location
    const { pathname } = useLocation();

	return (
    	<li className='Navigation__list-item'> 
        	<NavLink 
            	to="/events" 
                isActive={() => ['/events', '/myevents'].includes(pathname)} >
                Events 
            </NavLink> 
        </li>
    );
};
Posted by: Guest on June-06-2020

Code answers related to "multiple path name for same navlink"

Code answers related to "Javascript"

Browse Popular Code Answers by Language