Files
Mav-Mobile-UI/src/context/SightingFeedContext.ts

31 lines
948 B
TypeScript

import { createContext, useContext } from "react";
import type { SightingType } from "../types/types";
type SightingFeedContextType = {
sightings: (SightingType | null | undefined)[];
selectedRef: number | null;
setSelectedRef: (ref: number | null) => void;
// effectiveSelected: SightingType | null;
mostRecent: SightingType | null;
side: string;
selectedSighting: SightingType | null;
setSelectedSighting: (sighting: SightingType | SightingType | null) => void;
setSightingModalOpen: (isSightingModalOpen: boolean) => void;
isSightingModalOpen: boolean;
isError: boolean;
isLoading: boolean;
};
export const SightingFeedContext = createContext<
SightingFeedContextType | undefined
>(undefined);
export const useSightingFeedContext = () => {
const ctx = useContext(SightingFeedContext);
if (!ctx)
throw new Error(
"useSightingFeedContext must be used within SightingFeedProvider"
);
return ctx;
};