From 6bfe52d4e0578ea83761ff174ae6dc205b97a4ac Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 16 Oct 2022 17:43:03 -0700 Subject: Cache map click function --- modern/src/other/ReplayPage.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'modern/src') 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 && ( setShowCard(!!positionId)} + onClick={onMapClick} /> )} -- cgit v1.2.3