mirror of
https://github.com/remvze/moodist.git
synced 2025-12-17 00:44:14 +00:00
refactor: use nullish operator
This commit is contained in:
parent
ffe260f4a0
commit
9d633a9637
2 changed files with 3 additions and 4 deletions
|
|
@ -20,7 +20,7 @@ export function useSoundEffect(src: string, volume: number = 1) {
|
|||
}, [src, isBrowser]);
|
||||
|
||||
useEffect(() => {
|
||||
if (sound) sound.volume(typeof volume === 'number' ? volume : 1);
|
||||
if (sound) sound.volume(volume ?? 1);
|
||||
}, [sound, volume]);
|
||||
|
||||
const play = useCallback(() => {
|
||||
|
|
|
|||
|
|
@ -34,13 +34,12 @@ export function useSound(
|
|||
|
||||
useEffect(() => {
|
||||
if (sound) {
|
||||
sound.loop(typeof options.loop === 'boolean' ? options.loop : false);
|
||||
sound.loop(options.loop ?? false);
|
||||
}
|
||||
}, [sound, options.loop]);
|
||||
|
||||
useEffect(() => {
|
||||
if (sound)
|
||||
sound.volume(typeof options.volume === 'number' ? options.volume : 0.5);
|
||||
if (sound) sound.volume(options.volume ?? 0.5);
|
||||
}, [sound, options.volume]);
|
||||
|
||||
const play = useCallback(() => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue