mirror of
https://github.com/khairul169/garage-webui.git
synced 2025-09-18 19:19:31 +07:00
20 lines
433 B
TypeScript
20 lines
433 B
TypeScript
import { createContext, useContext } from "react";
|
|
import { Bucket } from "../types";
|
|
|
|
export const BucketContext = createContext<{
|
|
bucket: Bucket;
|
|
refetch: () => void;
|
|
bucketName: string;
|
|
} | null>(null);
|
|
|
|
export const useBucketContext = () => {
|
|
const bucket = useContext(BucketContext);
|
|
if (!bucket) {
|
|
throw new Error(
|
|
"BucketContext must be used within a BucketContextProvider"
|
|
);
|
|
}
|
|
|
|
return bucket;
|
|
};
|