UNPKG

react-navi

Version:

A batteries-included router for react.

47 lines (46 loc) 1.82 kB
import * as React from 'react'; import { URLDescriptor } from 'navi'; import { HashScrollBehavior } from './HashScroll'; export interface UseLinkPropsOptions { disabled?: boolean; hashScrollBehavior?: HashScrollBehavior; href: string | Partial<URLDescriptor>; prefetch?: boolean | 'hover' | 'mount'; state?: object; onClick?: React.MouseEventHandler<HTMLAnchorElement>; onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>; } /** * Returns a boolean that indicates whether the user is currently * viewing the specified href. * @param href * @param options.exact If false, will match any URL underneath this href * @param options.loading If true, will match even if the route is currently loading */ export declare const useActive: (href: string | Partial<URLDescriptor>, { exact, loading, }?: { /** * If false, will return true even if viewing a child of this route. */ exact?: boolean | undefined; /** * If true, this will return true even if the route is currently just * loading. */ loading?: boolean | undefined; }) => boolean; export declare const useLinkProps: ({ disabled, hashScrollBehavior, href, prefetch, state, onClick, onMouseEnter, }: UseLinkPropsOptions) => { onClick: (event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => void; onMouseEnter: (event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => void; href: string; }; export interface LinkProps extends UseLinkPropsOptions, Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> { active?: boolean; activeClassName?: string; activeStyle?: object; exact?: boolean; ref?: React.Ref<HTMLAnchorElement>; } export declare namespace Link { type Props = LinkProps; } export declare const Link: React.FunctionComponent<LinkProps>;