All files / app/common/dom preventDefault.ts

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14    149x     1242x 33x   33x 26x        
import { SyntheticEvent } from 'react';
 
export default function preventDefault<TFunc extends (event: TEvent, ...args: any[]) => any, TEvent extends SyntheticEvent>(
    fn?: TFunc
): (event: TEvent) => void {
    return event => {
        event.preventDefault();
 
        if (fn) {
            fn(event);
        }
    };
}