summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/util/effect-ref.js
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2023-03-26 21:49:26 +0100
committerFabian Mastenbroek <mail.fabianm@gmail.com>2023-03-27 20:31:30 +0100
commitefe1cebb4c1d8f07c0f1afb8bf08732d9fe20125 (patch)
treefd28183bb8754810403b4ef0e61f1a2088a8a29b /opendc-web/opendc-web-ui/src/util/effect-ref.js
parenta9da76621c1be7a11bf292e868a8f7c22f2ea203 (diff)
bug(web): Do not offset hover layer after dragging
This change fixes #136 which reported that the grid and cursor will fall out of sync when dragging or moving the grid when placing rooms or objects. Fixes #136
Diffstat (limited to 'opendc-web/opendc-web-ui/src/util/effect-ref.js')
-rw-r--r--opendc-web/opendc-web-ui/src/util/effect-ref.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/opendc-web/opendc-web-ui/src/util/effect-ref.js b/opendc-web/opendc-web-ui/src/util/effect-ref.js
index cda0324b..78528585 100644
--- a/opendc-web/opendc-web-ui/src/util/effect-ref.js
+++ b/opendc-web/opendc-web-ui/src/util/effect-ref.js
@@ -26,9 +26,9 @@ const noop = () => {}
/**
* A hook that will invoke the specified callback when the reference returned by this function is initialized.
- * The callback can return an optional clean up function.
+ * The callback can return an optional clean-up function.
*/
-export function useEffectRef(callback) {
+export function useEffectRef(callback, deps = []) {
const disposeRef = useRef(noop)
return useCallback((element) => {
disposeRef.current()
@@ -37,5 +37,5 @@ export function useEffectRef(callback) {
if (element) {
disposeRef.current = callback(element) || noop
}
- }, []) // eslint-disable-line react-hooks/exhaustive-deps
+ }, deps) // eslint-disable-line react-hooks/exhaustive-deps
}