replaced useMemo with useCallback

main
Inga 🏳‍🌈 1 year ago
parent 28ee56b4f2
commit 6dab7c18cc
  1. 9
      src/routePlanner/index.tsx

@ -1,5 +1,5 @@
import { nanoid } from 'nanoid';
import { useMemo, useState } from 'preact/hooks';
import { useCallback, useState } from 'preact/hooks';
import { reorderElements } from '../shared/collections';
import { Coordinates } from '../shared/types';
import { ExportComponent } from './export';
@ -12,8 +12,7 @@ import './style.css';
export const RoutePlanner = () => {
const [markers, setMarkers] = useState<Marker[]>([]);
const onMarkersReorder = useMemo(
() =>
const onMarkersReorder = useCallback(
({ oldIndex, newIndex }: ReorderMarkersParams): void =>
setMarkers((oldMarkers) => {
console.log(
@ -51,8 +50,8 @@ export const RoutePlanner = () => {
[],
);
const onMapClick = useMemo(
() => (coordinates: Coordinates) => {
const onMapClick = useCallback(
(coordinates: Coordinates) => {
setMarkers((markers) => [
...markers.slice(0, markers.length - 1),
...markers

Loading…
Cancel
Save