UNPKG

as-nav-link

Version:

React Router HOC that mimics NavLink functionality but just passes an active prop to child component.

14 lines (11 loc) 396 B
import React from 'react'; import { Link } from 'react-router-dom'; import NavLinkWithProp from 'nav-link-with-prop'; function asNavLink({ activeProp = 'active' } = {}) { return T => ({ children, ...props }) => ( <NavLinkWithProp {...props} activeProp={activeProp}> {innerProps => <T as={Link} {...innerProps}>{children}</T>} </NavLinkWithProp> ); } export default asNavLink;