Skip to content

Commit

Permalink
refactor: use nullish operator
Browse files Browse the repository at this point in the history
  • Loading branch information
remvze committed Jun 14, 2024
1 parent ffe260f commit 9d633a9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/hooks/use-sound-effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
5 changes: 2 additions & 3 deletions src/hooks/use-sound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down

0 comments on commit 9d633a9

Please sign in to comment.