@automattic/shopping-cart
Version:
A library to use the WordPress.com shopping cart.
14 lines • 810 B
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import useManagerClient from './use-manager-client';
import useShoppingCart from './use-shopping-cart';
export default function withShoppingCart(Component, mapPropsToCartKey) {
return function ShoppingCartWrapper(props) {
const cartKey = mapPropsToCartKey ? mapPropsToCartKey(props) : props.cartKey;
// Even though managerClient isn't used here this guard will provide a
// better error message than waiting for the one in useShoppingCart.
useManagerClient('withShoppingCart');
const shoppingCartManager = useShoppingCart(cartKey);
return (_jsx(Component, { ...props, shoppingCartManager: shoppingCartManager, cart: shoppingCartManager.responseCart }));
};
}
//# sourceMappingURL=with-shopping-cart.js.map