react-native-paper icon indicating copy to clipboard operation
react-native-paper copied to clipboard

feat: add debounce functionality to TouchableRipple

Open BohdanKhv opened this issue 4 months ago • 1 comments

  • Add optional debounce prop to prevent rapid successive presses
  • Implement debounce logic in both web and native TouchableRipple components
  • Add comprehensive test interface in TouchableRipple example
  • Update documentation with usage examples
  • Maintain backward compatibility with existing code

Motivation

Had to write extra code just to implement this in my apps


[!NOTE] Add optional debounce to TouchableRipple (web/native), wire it to onPress, and update examples and tests.

  • Components:
    • Add optional debounce prop to TouchableRipple (web: src/components/TouchableRipple/TouchableRipple.tsx, native: src/components/TouchableRipple/TouchableRipple.native.tsx).
    • Implement debouncedOnPress using Date.now() + ref; hook into Pressable via onPress={debouncedOnPress}.
    • Minor typing adjustments for PressableStateCallbackType on web.
  • Examples:
    • Revamp example/src/Examples/TouchableRippleExample.tsx with a scrollable demo showcasing basic ripple and a debounce test (normal vs debounced buttons, counters, reset).
  • Tests:
    • Extend src/components/__tests__/TouchableRipple.test.tsx to cover debounced vs non-debounced presses and existing behaviors.

Written by Cursor Bugbot for commit c77ad85a5b2e6df49beb392f4f8f6f99d9e9aca6. This will update automatically on new commits. Configure here.

BohdanKhv avatar Nov 02 '25 02:11 BohdanKhv

Hey @BohdanKhv, thank you for your pull request 🤗. The documentation from this branch can be viewed here.

callstack-bot avatar Nov 02 '25 02:11 callstack-bot