12 lines
326 B
TypeScript
12 lines
326 B
TypeScript
import { useContext } from "react";
|
|
import { InvoicesContext, InvoicesContextType } from "../context";
|
|
|
|
export const useInvoices = (): InvoicesContextType => {
|
|
const context = useContext(InvoicesContext);
|
|
if (!context) {
|
|
throw new Error("useInvoices must be used within a InvoicesProvider");
|
|
}
|
|
|
|
return context;
|
|
};
|