summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/components
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-07-07 11:46:57 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-07-07 11:46:57 +0200
commit1ce8bf170cda2afab334cd330325cd4fbb97dab4 (patch)
tree59911227f622a99844645b3276e73181777ab209 /opendc-web/opendc-web-ui/src/components
parentdfd2ded56780995cec6d91af37443b710d4ddb3b (diff)
ui: Split App container into separate components
This change splits the App container into separate pages, as a starting point for removing much of the unnecessary state from Redux.
Diffstat (limited to 'opendc-web/opendc-web-ui/src/components')
-rw-r--r--opendc-web/opendc-web-ui/src/components/app/map/MapStageComponent.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/opendc-web/opendc-web-ui/src/components/app/map/MapStageComponent.js b/opendc-web/opendc-web-ui/src/components/app/map/MapStageComponent.js
index 07b2d8f0..a8e156ec 100644
--- a/opendc-web/opendc-web-ui/src/components/app/map/MapStageComponent.js
+++ b/opendc-web/opendc-web-ui/src/components/app/map/MapStageComponent.js
@@ -1,3 +1,4 @@
+/* eslint-disable react-hooks/exhaustive-deps */
import PropTypes from 'prop-types'
import React, { useEffect, useRef, useState } from 'react'
import { HotKeys } from 'react-hotkeys'
@@ -37,10 +38,12 @@ function MapStageComponent({
setPos([mousePos.x, mousePos.y])
}
- useEffect(() => {
- const updateDimensions = () => setMapDimensions(window.innerWidth, window.innerHeight - NAVBAR_HEIGHT)
- const updateScale = (e) => zoomInOnPosition(e.deltaY < 0, x, y)
+ const updateDimensions = () => setMapDimensions(window.innerWidth, window.innerHeight - NAVBAR_HEIGHT)
+ const updateScale = (e) => zoomInOnPosition(e.deltaY < 0, x, y)
+ // We explicitly do not specify any dependencies to prevent infinitely dispatching updateDimensions commands
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ useEffect(() => {
updateDimensions()
window.addEventListener('resize', updateDimensions)
@@ -57,7 +60,7 @@ function MapStageComponent({
window.removeEventListener('resize', updateDimensions)
window.removeEventListener('wheel', updateScale)
}
- }, [x, y, setMapDimensions, zoomInOnPosition])
+ }, [])
const store = useStore()