1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-24 22:14:18 +00:00

🔧 Memoize mapArea

This commit is contained in:
Steffo 2021-05-25 15:58:52 +02:00
parent 4f274fa9af
commit c61f764c16
Signed by: steffo
GPG key ID: 6965406171929D01

View file

@ -1,4 +1,4 @@
import { useState } from "react"
import { useMemo, useState } from "react"
import Coordinates from "../objects/Coordinates"
import MapArea from "../objects/MapArea"
@ -9,7 +9,10 @@ import MapArea from "../objects/MapArea"
export default function useMapAreaState() {
const [zoom, setZoom] = useState(3)
const [center, setCenter] = useState(new Coordinates(0, 0))
const mapArea = MapArea.fromZoomLevel(zoom, center)
const mapArea = useMemo(
() => MapArea.fromZoomLevel(zoom, center),
[zoom, center]
)
return {
zoom,