Skip to content

Commit a023a8e

Browse files
committed
fix: remove debouncedpress useRef
1 parent 7270271 commit a023a8e

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/Button.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -158,19 +158,17 @@ const AwesomeButton = ({
158158
const pressAnimation = useRef<Animated.CompositeAnimation | null>(null);
159159
const [activity, setActivity] = useState(false);
160160
const [stateWidth, setStateWidth] = useState<number | null>(null);
161-
const debouncedPress = useRef(
162-
debouncedPressTime
163-
? debounce(
164-
(animateProgressEnd: (callback?: any) => void) =>
165-
onPress(animateProgressEnd),
166-
debouncedPressTime,
167-
{
168-
trailing: false,
169-
leading: true,
170-
}
171-
)
172-
: onPress
173-
);
161+
const debouncedPress = debouncedPressTime
162+
? debounce(
163+
(animateProgressEnd: (callback?: any) => void) =>
164+
onPress(animateProgressEnd),
165+
debouncedPressTime,
166+
{
167+
trailing: false,
168+
leading: true,
169+
}
170+
)
171+
: onPress;
174172

175173
const layout = {
176174
backgroundActive,
@@ -460,7 +458,7 @@ const AwesomeButton = ({
460458
requestAnimationFrame(startProgress);
461459
}
462460

463-
debouncedPress.current(animateProgressEnd);
461+
debouncedPress(animateProgressEnd);
464462
};
465463

466464
const handlePressIn = useCallback(

0 commit comments

Comments
 (0)