aboutsummaryrefslogtreecommitdiff
path: root/modern/src/other
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-10-16 17:43:03 -0700
committerAnton Tananaev <anton@traccar.org>2022-10-16 17:43:03 -0700
commit6bfe52d4e0578ea83761ff174ae6dc205b97a4ac (patch)
treecfd57b89334ac434a7167c3ebbacdb3ee605acef /modern/src/other
parentc85fcb9661cfa0e417fa24e1497fca3152f48f2f (diff)
downloadtrackermap-web-6bfe52d4e0578ea83761ff174ae6dc205b97a4ac.tar.gz
trackermap-web-6bfe52d4e0578ea83761ff174ae6dc205b97a4ac.tar.bz2
trackermap-web-6bfe52d4e0578ea83761ff174ae6dc205b97a4ac.zip
Cache map click function
Diffstat (limited to 'modern/src/other')
-rw-r--r--modern/src/other/ReplayPage.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/modern/src/other/ReplayPage.js b/modern/src/other/ReplayPage.js
index 67e44105..9d8503a8 100644
--- a/modern/src/other/ReplayPage.js
+++ b/modern/src/other/ReplayPage.js
@@ -1,5 +1,5 @@
import React, {
- useState, useEffect, useRef,
+ useState, useEffect, useRef, useCallback,
} from 'react';
import {
IconButton, Paper, Slider, Toolbar, Typography,
@@ -132,6 +132,10 @@ const ReplayPage = () => {
}
}, [index, positions]);
+ const onMapClick = useCallback((positionId) => {
+ setShowCard(!!positionId);
+ }, [setShowCard]);
+
const handleSubmit = useCatch(async ({ deviceId, from, to }) => {
setSelectedDeviceId(deviceId);
setFrom(from);
@@ -165,7 +169,7 @@ const ReplayPage = () => {
{index < positions.length && (
<MapPositions
positions={[positions[index]]}
- onClick={(positionId) => setShowCard(!!positionId)}
+ onClick={onMapClick}
/>
)}
</MapView>