Prevents the default handler of the given event.

Type signature

(event: {
    preventDefault: () => void;
}) => boolean

Examples

const event = {
  preventDefault: () =>
    console.log("preventDefault"),
  stopPropagation: () =>
    console.log("stopPropagation"),
};

prevent(event);
Try in REPL

Questions

  • How to prevent default event handler?

TypeScript sourceJavaScript source