2025-10-01 15:21:07 +01:00
|
|
|
import { useMemo, useReducer, type ReactNode } from "react";
|
2025-09-30 14:51:37 +01:00
|
|
|
import { SoundContext } from "../SoundContext";
|
2025-10-01 15:21:07 +01:00
|
|
|
import { initialState, reducer } from "../reducers/SoundContextReducer";
|
2025-09-30 14:51:37 +01:00
|
|
|
|
|
|
|
|
type SoundContextProviderProps = {
|
|
|
|
|
children: ReactNode;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const SoundContextProvider = ({ children }: SoundContextProviderProps) => {
|
2025-10-01 15:21:07 +01:00
|
|
|
const [state, dispatch] = useReducer(reducer, initialState);
|
|
|
|
|
const value = useMemo(() => ({ state, dispatch }), [state, dispatch]);
|
2025-09-30 14:51:37 +01:00
|
|
|
return (
|
2025-10-01 15:21:07 +01:00
|
|
|
<SoundContext.Provider value={value}>{children}</SoundContext.Provider>
|
2025-09-30 14:51:37 +01:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default SoundContextProvider;
|