-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve performance by ditching 'isPlaying'
- Loading branch information
1 parent
922711c
commit 6be141d
Showing
7 changed files
with
50 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react'; | ||
import useSound from '@'; | ||
|
||
import dunDunDunSfx from '../sounds/dun-dun-dun.mp3'; | ||
import Button from '../helpers/Button'; | ||
|
||
const ShowWhilePlaying = () => { | ||
const [isPlaying, setIsPlaying] = React.useState(false); | ||
|
||
const [playBoop] = useSound(dunDunDunSfx, { | ||
onplay: () => setIsPlaying(true), | ||
onend: () => setIsPlaying(false), | ||
}); | ||
|
||
return ( | ||
<> | ||
<h2>Is playing: {isPlaying.toString()}</h2> | ||
<br /> | ||
<Button onClick={playBoop}>Play sound</Button> | ||
</> | ||
); | ||
}; | ||
|
||
export default ShowWhilePlaying; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters