Skip to content

Commit

Permalink
Use ref for audio to prevent gatsby build error
Browse files Browse the repository at this point in the history
  • Loading branch information
billycougz committed Apr 25, 2023
1 parent 189614b commit dbc30dd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/pages/StartScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ const Nails = () => {
};

const StartScreen = () => {
const coinSound = new Audio(COIN_SOUND_IMPORT);
const coinSoundRef = React.useRef(null);
const playCoinSound = () => {
coinSound.play();
coinSoundRef.current.play();
};
return (
<Container>
Expand All @@ -146,6 +146,7 @@ const StartScreen = () => {
<Option href='https://github.com/billycougz' target='_blank'>
2 GITHUB
</Option>
<audio ref={coinSoundRef} src={COIN_SOUND_IMPORT} />
</OptionContainer>
</Sky>
<Hill />
Expand Down

0 comments on commit dbc30dd

Please sign in to comment.