- Implement CameraFeed context and provider with reducer for state management

- able to switch footage on tab clicks
This commit is contained in:
2025-11-27 10:43:56 +00:00
parent 6accac02de
commit 1ada8d0966
9 changed files with 101 additions and 10 deletions

View File

@@ -0,0 +1,16 @@
import { createContext, useContext } from "react";
import type { CameraFeedAction, CameraFeedState } from "../../types/types";
type CameraFeedContextType = {
state: CameraFeedState;
// check and refactor
dispatch: (state: CameraFeedAction) => void;
};
export const CameraFeedContext = createContext<CameraFeedContextType | null>(null);
export const useCameraFeedContext = () => {
const ctx = useContext(CameraFeedContext);
if (!ctx) throw new Error("useCameraFeedContext must be used inside <CameraFeedContext.Provider>");
return ctx;
};