import React, { useEffect, useRef } from "react";
const OnButtonClick = (props) => {
    const theRef = useRef(null);
    const { onClick } = props;
    useEffect(() => {
        const div = theRef.current;
        if (!div) {
            return;
        }
        const cb = (e) => {
            if (e.target instanceof HTMLElement && e.target.nodeName.toLowerCase() === "button") {
                setTimeout(() => {
                    onClick();
                }, 0);
            }
        };
        div.addEventListener("click", cb);
        return () => { div.removeEventListener("click", cb); };
    }, [onClick]);
    return React.createElement("div", { ref: theRef }, props.children);
};
export { OnButtonClick };
//# sourceMappingURL=OnButtonClick.js.map