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