Function useLiteInteraction

  • Custom React hook that detects user interaction with a specified element.

    This hook listens for both touchstart and mousedown events on the provided reference element and triggers the specified effect when these events occur. It is useful for detecting user interactions in both touch and mouse environments.

    Example

    const MyComponent = () => {
    const ref = useRef<HTMLDivElement>(null);

    const handleInteraction = () => {
    console.log('User interacted with the element!');
    };

    useLiteInteraction(ref, handleInteraction);

    return <div ref={ref}>Interact with me!</div>;
    };

    Parameters

    • ref: RefObject<Element>

      A reference to the target element to monitor for user interaction.

    • effect: (() => void)

      The effect callback to be executed when the interaction is detected.

        • (): void
        • Returns void

    Returns void