We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent acce706 commit 6892fb7Copy full SHA for 6892fb7
index.js
@@ -98,6 +98,10 @@ export function useClickAway(cb) {
98
const ref = React.useRef(null);
99
const refCb = React.useRef(cb);
100
101
+ React.useLayoutEffect(() => {
102
+ refCb.current = cb;
103
+ });
104
+
105
React.useEffect(() => {
106
const handler = (e) => {
107
const element = ref.current;
@@ -591,6 +595,10 @@ export function useLongPress(
591
595
const timerId = React.useRef();
592
596
const cbRef = React.useRef(callback);
593
597
598
599
+ cbRef.current = callback;
600
601
594
602
const start = React.useCallback(
603
() => (event) => {
604
if (isPressed.current) return;
0 commit comments