Skip to content

Commit

Permalink
processes the change of current in the reference for certain hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
UpperCod committed Dec 21, 2021
1 parent 5de3a2d commit 64ba767
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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/**/*"
Expand Down
2 changes: 1 addition & 1 deletion src/use-click-coordinates/use-click-coordinates.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function useClickCoordinates(ref, callback) {
},
true
);
}, [ref]);
}, [ref, ref?.current]);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/use-keyboard/use-keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ export function useKeyboard(ref, keys, callback) {
removeKeydown();
removeKeyup();
};
}, keys);
}, [ref, ref?.current, ...keys]);
}
2 changes: 1 addition & 1 deletion src/use-listener/use-listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/use-mutation-observer/use-mutation-observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function useMutationObserver(ref, observe, config) {
);
observer.observe(ref.current, config);
return () => observer.disconnect();
}, [ref]);
}, [ref, ref?.current]);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/use-resize-observer/use-resize-observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function useResizeObserver(ref, callback) {
resizeObserver.unobserve(current);
}
};
}, [ref]);
}, [ref, ref?.current]);
}

/**
Expand Down
2 changes: 0 additions & 2 deletions src/use-slot/use-slot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 64ba767

Please sign in to comment.