mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-22 04:54: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 Coordinates from "../objects/Coordinates"
|
||||||
import MapArea from "../objects/MapArea"
|
import MapArea from "../objects/MapArea"
|
||||||
|
|
||||||
|
@ -9,7 +9,10 @@ import MapArea from "../objects/MapArea"
|
||||||
export default function useMapAreaState() {
|
export default function useMapAreaState() {
|
||||||
const [zoom, setZoom] = useState(3)
|
const [zoom, setZoom] = useState(3)
|
||||||
const [center, setCenter] = useState(new Coordinates(0, 0))
|
const [center, setCenter] = useState(new Coordinates(0, 0))
|
||||||
const mapArea = MapArea.fromZoomLevel(zoom, center)
|
const mapArea = useMemo(
|
||||||
|
() => MapArea.fromZoomLevel(zoom, center),
|
||||||
|
[zoom, center]
|
||||||
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
zoom,
|
zoom,
|
||||||
|
|
Loading…
Reference in a new issue