Refactor sound context and update sound settings functionality; remove console logs and improve sound file handling
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
import { useReducer, type ReactNode } from "react";
|
||||
import { useMemo, useReducer, type ReactNode } from "react";
|
||||
import { SoundContext } from "../SoundContext";
|
||||
import { initalState, reducer } from "../reducers/SoundContextReducer";
|
||||
import { initialState, reducer } from "../reducers/SoundContextReducer";
|
||||
|
||||
type SoundContextProviderProps = {
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
const SoundContextProvider = ({ children }: SoundContextProviderProps) => {
|
||||
const [state, dispatch] = useReducer(reducer, initalState);
|
||||
const [state, dispatch] = useReducer(reducer, initialState);
|
||||
const value = useMemo(() => ({ state, dispatch }), [state, dispatch]);
|
||||
return (
|
||||
<SoundContext.Provider value={{ state, dispatch }}>
|
||||
{children}
|
||||
</SoundContext.Provider>
|
||||
<SoundContext.Provider value={value}>{children}</SoundContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user