diff --git a/web/src/components/CameraControlPanel.jsx b/web/src/components/CameraControlPanel.jsx
index fe5b12a60..394d41794 100644
--- a/web/src/components/CameraControlPanel.jsx
+++ b/web/src/components/CameraControlPanel.jsx
@@ -1,5 +1,5 @@
import { h } from 'preact';
-import { useState } from 'preact/hooks';
+import { useEffect, useCallback, useState } from 'preact/hooks';
import useSWR from 'swr';
import { usePtzCommand } from '../api/ws';
import ActivityIndicator from './ActivityIndicator';
@@ -27,29 +27,25 @@ export default function CameraControlPanel({ camera = '' }) {
setCurrentPreset('');
};
- const onSetMove = async (e, dir) => {
+ const onSetMove = useCallback(async (e, dir) => {
e.stopPropagation();
sendPtz(`MOVE_${dir}`);
setCurrentPreset('');
- };
+ }, [sendPtz, setCurrentPreset]);
- const onSetZoom = async (e, dir) => {
+ const onSetZoom = useCallback(async (e, dir) => {
e.stopPropagation();
sendPtz(`ZOOM_${dir}`);
setCurrentPreset('');
- };
+ }, [sendPtz, setCurrentPreset]);
- const onSetStop = async (e) => {
+ const onSetStop = useCallback(async (e) => {
e.stopPropagation();
sendPtz('STOP');
- };
+ }, [sendPtz]);
- if (!ptz) {
- return