12 lines
340 B
TypeScript
12 lines
340 B
TypeScript
import { useContext } from "react";
|
|
import { CustomersContext, CustomersContextType } from "../context";
|
|
|
|
export const useCustomersContext = (): CustomersContextType => {
|
|
const context = useContext(CustomersContext);
|
|
if (!context) {
|
|
throw new Error("useCustomers must be used within a CustomersProvider");
|
|
}
|
|
|
|
return context;
|
|
};
|