UNPKG

react-sounds

Version:

A library of ready-to-play sound effects for React applications.

27 lines (26 loc) 1.02 kB
/// <reference types="react" /> import { SoundName } from "./runtime"; import { SoundHookReturn, SoundOptions } from "./types"; interface SoundContextType { enabled: boolean; setEnabled: (enabled: boolean) => void; } type SoundContextValue = React.Context<SoundContextType | null>; export declare function setSoundContext(context: SoundContextValue): void; /** * Hook for using a sound in a React component. * Will use local bundled sounds if available before falling back to remote. */ export declare function useSound(soundName: SoundName, defaultOptions?: SoundOptions): SoundHookReturn; interface UseSoundOnChangeOptions extends SoundOptions { initial?: boolean; } /** * Hook for playing a sound when a value changes */ export declare function useSoundOnChange<T>(soundName: SoundName, value: T, options?: UseSoundOnChangeOptions): void; /** * Hook for accessing and controlling the sound enabled state */ export declare function useSoundEnabled(): [boolean, (enabled: boolean) => void]; export {};