UNPKG

@shopify/hydrogen-react

Version:

React components, hooks, and utilities for creating custom Shopify storefronts

30 lines (29 loc) 955 B
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const jsxRuntime = require("react/jsx-runtime"); const React = require("react"); function BaseButton(props) { const { as, onClick, defaultOnClick, children, buttonRef, ...passthroughProps } = props; const handleOnClick = React.useCallback( (event) => { if (onClick) { const clickShouldContinue = onClick(event); if (typeof clickShouldContinue === "boolean" && clickShouldContinue === false || (event == null ? void 0 : event.defaultPrevented)) return; } defaultOnClick == null ? void 0 : defaultOnClick(event); }, [defaultOnClick, onClick] ); const Component = as || "button"; return /* @__PURE__ */ jsxRuntime.jsx(Component, { ref: buttonRef, onClick: handleOnClick, ...passthroughProps, children }); } exports.BaseButton = BaseButton; //# sourceMappingURL=BaseButton.js.map