UNPKG

preact-context-menu

Version:
16 lines 655 B
import { h } from "preact"; import { useCallback } from "preact/hooks"; import { MenuContext } from "./menu"; var MenuItem = function (props) { var onClick = useCallback(function (event, fn, data) { if (props.disabled === true) return; event.stopPropagation(); if (fn === undefined) throw new Error("MenuItem is not inside a ContextMenu"); fn(data); }, []); return (h(MenuContext.Consumer, null, function (fn) { return (h("span", { onClick: function (event) { return onClick(event, fn, props.data); } }, props.children)); })); }; export default MenuItem; //# sourceMappingURL=item.js.map