Files
Mav-Mobile-UI/src/context/providers/SoundContextProvider.tsx

18 lines
590 B
TypeScript
Raw Normal View History

import { useMemo, useReducer, type ReactNode } from "react";
import { SoundContext } from "../SoundContext";
import { initialState, reducer } from "../reducers/SoundContextReducer";
type SoundContextProviderProps = {
children: ReactNode;
};
const SoundContextProvider = ({ children }: SoundContextProviderProps) => {
const [state, dispatch] = useReducer(reducer, initialState);
const value = useMemo(() => ({ state, dispatch }), [state, dispatch]);
return (
<SoundContext.Provider value={value}>{children}</SoundContext.Provider>
);
};
export default SoundContextProvider;