Skip to content

Commit

Permalink
refactor: moved the bell sound creation inside the callback hook
Browse files Browse the repository at this point in the history
  • Loading branch information
sekwah41 committed Dec 20, 2022
1 parent deb5d7d commit cc8ffec
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/renderer/src/routes/Timer/Control/Control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ type Props = {
};

const Control: React.FC<Props> = ({ resetTimerAction }) => {
const warnSound = new Audio(WarningBell);

const { timer, config } = useSelector((state: AppStateTypes) => ({
timer: state.timer,
config: state.config,
Expand All @@ -51,9 +49,11 @@ const Control: React.FC<Props> = ({ resetTimerAction }) => {
const [warn, setWarn] = useState(false);

const activateWarning = useCallback(() => {
const warnSound = new Audio(WarningBell);

setWarn(true);
warnSound.play();
}, [warnSound]);
}, []);

const onResetCallback = useCallback(() => {
if (timer.playing && settings.enableStrictMode) {
Expand Down

0 comments on commit cc8ffec

Please sign in to comment.