react-navplus
Version:
A flexible, performance-optimized navigation link component for React with multi-router support, prefetching, and advanced active state detection
37 lines • 1.25 kB
TypeScript
import { PrefetchOptions } from '../types';
/**
* Hook for handling prefetching of link targets with timeout management
*
* @param {string} to - The URL to prefetch
* @param {object} options - Options for prefetching
* @param {boolean | PrefetchOptions} options.prefetch - Prefetch configuration
* @param {boolean} options.isExternal - Whether the URL is external
* @param {boolean} options.redirection - Whether redirection is enabled
* @param {boolean} options.disabled - Whether the link is disabled
* @param {any} options.routerContext - Router context for accessing router instance
* @returns {object} - Prefetch state and handlers
*
* @example
* // Basic usage
* const { isPrefetched, handlePrefetch } = usePrefetch('/dashboard', {
* prefetch: true,
* isExternal: false
* });
*
* // When mouse enters the link
* const handleMouseEnter = () => {
* handlePrefetch();
* };
*/
export declare function usePrefetch(to: string, options?: {
prefetch?: boolean | PrefetchOptions;
isExternal?: boolean;
redirection?: boolean;
disabled?: boolean;
routerContext?: any;
}): {
isPrefetched: boolean;
handlePrefetch: () => void;
cancelPrefetch: () => void;
};
//# sourceMappingURL=usePrefetch.d.ts.map