React Router API Reference
    Preparing search index...

    Function useLinkClickHandler

    • Handles the click behavior for router <Link> components.This is useful if you need to create custom <Link> components with the same click behavior we use in our exported <Link>.

      Type Parameters

      • E extends Element = HTMLAnchorElement

      Parameters

      • to: To

        The URL to navigate to, can be a string or a partial Path.

      • options: {
            preventScrollReset?: boolean;
            relative?: RelativeRoutingType;
            replace?: boolean;
            state?: any;
            target?: HTMLAttributeAnchorTarget;
            unstable_defaultShouldRevalidate?: boolean;
            unstable_useTransitions?: boolean;
            viewTransition?: boolean;
        } = {}

        Options

        • OptionalpreventScrollReset?: boolean

          Whether to prevent the scroll position from being reset to the top of the viewport on completion of the navigation when using the ScrollRestoration component. Defaults to false.

        • Optionalrelative?: RelativeRoutingType

          The relative routing type to use for the link. Defaults to "route".

        • Optionalreplace?: boolean

          Whether to replace the current History entry instead of pushing a new one. Defaults to false.

        • Optionalstate?: any

          The state to add to the History entry for this navigation. Defaults to undefined.

        • Optionaltarget?: HTMLAttributeAnchorTarget

          The target attribute for the link. Defaults to undefined.

        • Optionalunstable_defaultShouldRevalidate?: boolean

          Specify the default revalidation behavior for the navigation. Defaults to true.

        • Optionalunstable_useTransitions?: boolean

          Wraps the navigation in React.startTransition for concurrent rendering. Defaults to false.

        • OptionalviewTransition?: boolean

          Enables a View Transition for this navigation. To apply specific styles during the transition, see useViewTransitionState. Defaults to false.

      Returns (event: MouseEvent<E, MouseEvent>) => void

      A click handler function that can be used in a custom Link component.