got to a good point with sighting modal, want to do cleanup
This commit is contained in:
30
src/context/SightingFeedContext.ts
Normal file
30
src/context/SightingFeedContext.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { createContext, useContext } from "react";
|
||||
import type { SightingType, SightingWidgetType } from "../types/types";
|
||||
|
||||
type SightingFeedContextType = {
|
||||
sightings: (SightingWidgetType | null | undefined)[];
|
||||
selectedRef: number | null;
|
||||
setSelectedRef: (ref: number | null) => void;
|
||||
// effectiveSelected: SightingWidgetType | null;
|
||||
mostRecent: SightingWidgetType | null;
|
||||
side: string;
|
||||
selectedSighting: SightingType | null;
|
||||
setSelectedSighting: (
|
||||
sighting: SightingType | SightingWidgetType | null
|
||||
) => void;
|
||||
setSightingModalOpen: (isSightingModalOpen: boolean) => void;
|
||||
isSightingModalOpen: 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;
|
||||
};
|
||||
Reference in New Issue
Block a user