Add CameraSettings context and provider; integrate into AppProviders and VideoFeed
This commit is contained in:
16
src/app/context/CameraSettingsContext.ts
Normal file
16
src/app/context/CameraSettingsContext.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { createContext, useContext } from "react";
|
||||
import type { CameraSettings, CameraSettingsAction } from "../../utils/types";
|
||||
|
||||
type CameraSettingsContextType = {
|
||||
state: CameraSettings;
|
||||
dispatch: (state: CameraSettingsAction) => void;
|
||||
};
|
||||
export const CameraSettingsContext = createContext<CameraSettingsContextType | null>(null);
|
||||
|
||||
export const useCameraSettingsContext = () => {
|
||||
const context = useContext(CameraSettingsContext);
|
||||
if (!context) {
|
||||
throw new Error("useCameraSettingsContext must be used within a CameraSettingsProvider");
|
||||
}
|
||||
return context;
|
||||
};
|
||||
Reference in New Issue
Block a user