with-custom-cursor
Version:
A Higher-Order Component (HOC) library for React that enables you to easily add a custom cursor to any component.
16 lines (15 loc) • 808 B
TypeScript
import { ComponentType, RefObject } from 'react';
type RequireRef<T extends HTMLElement> = {
/**
* The cursor component must accept a 'ref' prop of type RefObject<HTMLElement>.
* This ref is automatically provided by WithCustomCursor - you don't need to pass it manually.
*
* Example:
* const Cursor = ({ label, ref }: { label: string; ref: RefObject<HTMLDivElement> }) => (
* <div ref={ref}>{label}</div>
* )
*/
ref: RefObject<T>;
};
export declare const WithCustomCursor: <P extends object, T extends HTMLElement = HTMLElement, CursorProps extends RequireRef<T> = RequireRef<T>>(WrappedComponent: ComponentType<P>, CursorComponent: ComponentType<CursorProps>) => (props: P & Omit<CursorProps, "ref">) => import("react/jsx-runtime").JSX.Element;
export {};