11 lines
274 B
TypeScript
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;
|
|
}
|