mirror of
https://github.com/remvze/moodist.git
synced 2025-12-17 08:54:13 +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]);
|
}, [src, isBrowser]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (sound) sound.volume(typeof volume === 'number' ? volume : 1);
|
if (sound) sound.volume(volume ?? 1);
|
||||||
}, [sound, volume]);
|
}, [sound, volume]);
|
||||||
|
|
||||||
const play = useCallback(() => {
|
const play = useCallback(() => {
|
||||||
|
|
|
||||||
|
|
@ -34,13 +34,12 @@ export function useSound(
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (sound) {
|
if (sound) {
|
||||||
sound.loop(typeof options.loop === 'boolean' ? options.loop : false);
|
sound.loop(options.loop ?? false);
|
||||||
}
|
}
|
||||||
}, [sound, options.loop]);
|
}, [sound, options.loop]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (sound)
|
if (sound) sound.volume(options.volume ?? 0.5);
|
||||||
sound.volume(typeof options.volume === 'number' ? options.volume : 0.5);
|
|
||||||
}, [sound, options.volume]);
|
}, [sound, options.volume]);
|
||||||
|
|
||||||
const play = useCallback(() => {
|
const play = useCallback(() => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue