RocketChat/Rocket.Chat

View on GitHub
apps/meteor/client/hooks/usePreventPropagation.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { useEffectEvent } from '@rocket.chat/fuselage-hooks';
import type { UIEvent } from 'react';

export const usePreventPropagation = (fn?: (e: UIEvent) => void): ((e: UIEvent) => void) => {
    const preventClickPropagation = useEffectEvent((e): void => {
        e.stopPropagation();
        fn?.(e);
    });
    return preventClickPropagation;
};