react-router-dom#LinkProps TypeScript Examples
The following examples show how to use
react-router-dom#LinkProps.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SchemaExplorer.tsx From json-schema-viewer with Apache License 2.0 | 6 votes |
BackButton: React.FC<LinkProps> = props => {
const history = useHistory();
return (
<Button
key="backButton"
iconBefore={<ChevronLeftIcon label="Back" />}
href={props.href}
onClick={e => {
e.preventDefault();
history.push(props.href || '');
}}
>Back
</Button>
);
}
Example #2
Source File: router.tsx From polkabtc-ui with Apache License 2.0 | 6 votes |
InterlayRouterLink = ({ className, children, ...rest }: LinkProps): JSX.Element => ( <Link className={clsx( styles['interlay-link'], 'text-black', className )} {...rest}> {children} </Link> )
Example #3
Source File: index.tsx From wildduck-ui with MIT License | 6 votes |
/**
* CustomLink to prefix basepath for to
* @param props
*/
function CustomLink <S = unknown>(props: LinkProps<S> & React.RefAttributes<HTMLAnchorElement> ): ReturnType<Link<S>> {
const {to, children, ...restProps} = props;
return (
<Link {...restProps} to={`${getBasePath()}${to}`} > {children} </Link>
);
}
Example #4
Source File: Link.tsx From querybook with Apache License 2.0 | 5 votes |
Link: React.FC<ILinkProps> = ({
to,
onClick,
newTab,
children,
naturalLink,
stopProgation,
linkProps,
...elementProps
}) => {
const handleClick = useCallback(
(e: React.MouseEvent<HTMLAnchorElement>) => {
if (e.button !== 0) {
// If it is not a left click, ignore
return;
}
e.preventDefault();
const isCmdDown = e.metaKey;
if (onClick) {
onClick(e);
} else if (to && typeof to === 'string') {
if (isCmdDown || newTab) {
openNewTab(to);
} else {
openInTab(to);
}
}
},
[to, onClick, newTab]
);
const linkComponent = isInternalUrl(to) ? (
<LinkImport to={to} {...(elementProps as LinkProps)} {...linkProps}>
{children}
</LinkImport>
) : (
<StyledLink
href={to}
naturalLink={naturalLink}
onMouseDown={handleClick}
{...elementProps}
{...(newTab
? {}
: { target: '_blank', rel: 'noopener noreferrer' })}
>
{children}
</StyledLink>
);
if (stopProgation) {
return <span onClick={stopPropagationFunc}>{linkComponent}</span>;
}
return linkComponent;
}
Example #5
Source File: LinkButton.tsx From smart-tracing with Apache License 2.0 | 5 votes |
LinkButton = ({ ...props }: LinkProps & ButtonProps) => <Button as={Link} {...props} />
Example #6
Source File: LinkCard.tsx From smart-tracing with Apache License 2.0 | 5 votes |
LinkCard = ({ to, ...props }: LinkProps & InfoCardProps) => (
<Link to={to}>
<InfoCard {...props} />
</Link>
)
Example #7
Source File: NavLink.tsx From smart-tracing with Apache License 2.0 | 5 votes |
NavLink = ({ ...props }: NavLinkProps & LinkProps) => (
<Nav.Item>
<Nav.Link as={Link} {...props} />
</Nav.Item>
)