- Implement CameraFeed context and provider with reducer for state management
- able to switch footage on tab clicks
This commit is contained in:
17
src/app/reducers/cameraFeedReducer.ts
Normal file
17
src/app/reducers/cameraFeedReducer.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { CameraFeedAction, CameraFeedState } from "../../types/types";
|
||||
|
||||
export const initialState: CameraFeedState = {
|
||||
cameraFeedID: "A",
|
||||
};
|
||||
|
||||
export function reducer(state: CameraFeedState, action: CameraFeedAction) {
|
||||
switch (action.type) {
|
||||
case "SET_CAMERA_FEED":
|
||||
return {
|
||||
...state,
|
||||
cameraFeedID: action.payload,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user