Files
projet_gestion_commande/frontend-prep/src/context/useCart.ts
T
2026-03-19 19:56:51 +01:00

11 lines
274 B
TypeScript

import { useContext } from "react";
import { CartContext } from "./CartContext";
export function useCart() {
const context = useContext(CartContext);
if (!context) {
throw new Error("useCart must be used within a CartProvider");
}
return context;
}