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:
parent
4f274fa9af
commit
c61f764c16
1 changed files with 5 additions and 2 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue