10 lines
339 B
TypeScript
10 lines
339 B
TypeScript
import { useContext } from "react";
|
|
import { PlayerContext, PlayerContextValue } from "./PlayerProvider";
|
|
|
|
export function usePlayerContext() : PlayerContextValue {
|
|
const context = useContext(PlayerContext);
|
|
if (!context) {
|
|
throw new Error("useAudioPlayer must be used within a PlayerProvider");
|
|
}
|
|
return context;
|
|
} |