mirror of https://github.com/ctk-hq/ctk
feat: created `useTabContext` hook
parent
9b7ec85bdb
commit
0896996f22
@ -1,2 +1,3 @@
|
||||
export * from "./useTitle";
|
||||
export * from "./useAccordionState";
|
||||
export * from "./useTabContext";
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
import { TabContext } from "../contexts";
|
||||
import { ITabContext } from "../types";
|
||||
|
||||
export const useTabContext = (): ITabContext => {
|
||||
const context = useContext(TabContext);
|
||||
if (!context) {
|
||||
throw new Error("Cannot find tab context.");
|
||||
}
|
||||
return context;
|
||||
};
|
||||
Loading…
Reference in New Issue