Remove dependency comments and use useRef instead for useSound hook (#117)

* Remove dependency comments and use useRef instead for useSound hook

* Handle change URL volume and loop gracefully
This commit is contained in:
J Francisco Rader authored and GitHub committed 2021-02-27 15:10:59 -05:00
1 parent 54bdd07e9c
commit 9cfc3fa8ec
2 files changed
+52 -36

No files matched your search

@@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import { AppWrapper } from '../../../ui/components';
import { AppContent } from '../../../ui/components/AppContent';
@@ -6,12 +6,17 @@ import { useApp } from '../../../os/apps/hooks/useApps';
import { useExample } from '../hooks/useExample';
import { ExampleThemeProvider } from '../providers/ExampleThemeProvider';
import { AppTitle } from '../../../ui/components/AppTitle';
import { Button } from '@material-ui/core';
import PlayIcon from '@material-ui/icons/PlayArrow';
import StopIcon from '@material-ui/icons/Stop';
import { Button, IconButton } from '@material-ui/core';
import useSound from '../../../os/phone/hooks/useSound';
export const ExampleApp = () => {
// calling the example hook, and we assign the value to a variable
const exampleString = useExample();
const example = useApp('EXAMPLE');
const [soundName, setSound] = useState('pixel.ogg');
const { play, playing, stop } = useSound('media/ringtones/' + soundName);
return (
<ExampleThemeProvider>
<AppWrapper>
@@ -21,6 +26,12 @@ export const ExampleApp = () => {
<Button color='primary'>{example.id}</Button>
{/* Here we are using the value in a h3 tag */}
<h3>{exampleString}</h3>
<IconButton onClick={() => (playing ? stop() : play())}>
{playing ? <StopIcon /> : <PlayIcon />}
</IconButton>
<Button onClick={() => setSound('marimba.ogg')}>
Change sound on the fly
</Button>
</AppContent>
</AppWrapper>
</ExampleThemeProvider>