Download tabler-react/src/components/Nav/NavLink.react.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/tabler-react/src/components/Nav/NavLink.react.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/tabler-react/src/components/Nav/NavLink.react.js
-
curl -L -o NavLink.react.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/tabler-react/src/components/Nav/NavLink.react.js
1.1 kB
| // @flow | |
| import * as React from "react"; | |
| import cn from "classnames"; | |
| import Icon from "../Icon"; | |
| type Props = {| | |
| +children?: React.Node, | |
| +className?: string, | |
| +RootComponent?: React.ElementType, | |
| +active?: boolean, | |
| +icon?: string, | |
| +to?: string, | |
| +hasSubNav?: boolean, | |
| +rootRef?: (?HTMLElement) => void, | |
| +useExact?: boolean, | |
| |}; | |
| function NavLink({ | |
| children, | |
| className, | |
| RootComponent, | |
| icon, | |
| active = false, | |
| to, | |
| hasSubNav, | |
| rootRef, | |
| useExact, | |
| }: Props): React.Node { | |
| const classes = cn({ "nav-link": true, active: active }, className); | |
| const childrenForAll = ( | |
| <React.Fragment> | |
| {icon && ( | |
| <React.Fragment> | |
| <Icon name={icon} />{" "} | |
| </React.Fragment> | |
| )} | |
| {children} | |
| </React.Fragment> | |
| ); | |
| return RootComponent ? ( | |
| <RootComponent exact={useExact || false} className={classes} to={to}> | |
| {childrenForAll} | |
| </RootComponent> | |
| ) : ( | |
| <a className={classes} href={to} ref={rootRef}> | |
| {childrenForAll} | |
| </a> | |
| ); | |
| } | |
| NavLink.displayName = "Nav.Link"; | |
| /** @component */ | |
| export default NavLink; | |