diff --git a/package.json b/package.json index 64dd66a..0132ba1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@atomico/hooks", "description": "Series of utilities in hooks format to extend the operation of Atomico", - "version": "3.22.0", + "version": "3.23.0", "type": "module", "workspaces": [ "src/**/*" diff --git a/src/use-click-coordinates/use-click-coordinates.js b/src/use-click-coordinates/use-click-coordinates.js index 8941adc..49349de 100644 --- a/src/use-click-coordinates/use-click-coordinates.js +++ b/src/use-click-coordinates/use-click-coordinates.js @@ -23,7 +23,7 @@ export function useClickCoordinates(ref, callback) { }, true ); - }, [ref]); + }, [ref, ref?.current]); } /** diff --git a/src/use-keyboard/use-keyboard.js b/src/use-keyboard/use-keyboard.js index 4d732bc..4574ccb 100644 --- a/src/use-keyboard/use-keyboard.js +++ b/src/use-keyboard/use-keyboard.js @@ -36,5 +36,5 @@ export function useKeyboard(ref, keys, callback) { removeKeydown(); removeKeyup(); }; - }, keys); + }, [ref, ref?.current, ...keys]); } diff --git a/src/use-listener/use-listener.js b/src/use-listener/use-listener.js index 104b618..d72049b 100644 --- a/src/use-listener/use-listener.js +++ b/src/use-listener/use-listener.js @@ -12,7 +12,7 @@ export function useListener(ref, name, handler, options) { const { current } = ref; if (!current || !handler) return; return addListener(current, name, (event) => value.current(event), options); - }, [name, !!handler]); + }, [ref, ref?.current, name, !!handler]); } /** diff --git a/src/use-mutation-observer/use-mutation-observer.js b/src/use-mutation-observer/use-mutation-observer.js index bf2bff9..0ca3c20 100644 --- a/src/use-mutation-observer/use-mutation-observer.js +++ b/src/use-mutation-observer/use-mutation-observer.js @@ -21,7 +21,7 @@ export function useMutationObserver(ref, observe, config) { ); observer.observe(ref.current, config); return () => observer.disconnect(); - }, [ref]); + }, [ref, ref?.current]); } /** diff --git a/src/use-resize-observer/use-resize-observer.js b/src/use-resize-observer/use-resize-observer.js index 6a53926..ca029f2 100644 --- a/src/use-resize-observer/use-resize-observer.js +++ b/src/use-resize-observer/use-resize-observer.js @@ -46,7 +46,7 @@ export function useResizeObserver(ref, callback) { resizeObserver.unobserve(current); } }; - }, [ref]); + }, [ref, ref?.current]); } /** diff --git a/src/use-slot/use-slot.js b/src/use-slot/use-slot.js index 825df82..3dc9263 100644 --- a/src/use-slot/use-slot.js +++ b/src/use-slot/use-slot.js @@ -11,8 +11,6 @@ export function useSlot(ref) { useEffect(() => { const { current } = ref; if (!current) return; - const type = "slotchange"; - // handler subscriber to the event const handler = () => setChildNodes(