1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-22 10:22:31 +01:00

fix react warning

This commit is contained in:
Mikael Finstad 2023-04-08 23:51:19 +09:00
parent 3bc407cabd
commit 2830ec0e9b
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26

View File

@ -10,7 +10,9 @@ const BigWaveform = memo(({ waveforms, relevantTime, playing, durationSafe, zoom
const scaleFactor = zoom;
const [smoothTime, setSmoothTime] = useState(relevantTime);
const [smoothTimeRaw, setSmoothTime] = useState(relevantTime);
const smoothTime = smoothTimeRaw ?? relevantTime;
const mouseDownRef = useRef();
const containerRef = useRef();
@ -47,8 +49,6 @@ const BigWaveform = memo(({ waveforms, relevantTime, playing, durationSafe, zoom
useEffect(() => {
let time = relevantTime;
setSmoothTime(time);
const startTime = new Date().getTime();
if (playing) {
@ -56,7 +56,6 @@ const BigWaveform = memo(({ waveforms, relevantTime, playing, durationSafe, zoom
// eslint-disable-next-line no-inner-declarations
function render() {
raf = window.requestAnimationFrame(() => {
time = new Date().getTime() / 1000;
setSmoothTime(relevantTime + (new Date().getTime() - startTime) / 1000);
render();
});
@ -66,6 +65,8 @@ const BigWaveform = memo(({ waveforms, relevantTime, playing, durationSafe, zoom
return () => window.cancelAnimationFrame(raf);
}
setSmoothTime(undefined);
return undefined;
}, [relevantTime, playing]);