react-native-paper
react-native-paper copied to clipboard
feat: add debounce functionality to TouchableRipple
- 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 toonPress, and update examples and tests.
- Components:
- Add optional
debounceprop toTouchableRipple(web:src/components/TouchableRipple/TouchableRipple.tsx, native:src/components/TouchableRipple/TouchableRipple.native.tsx).- Implement
debouncedOnPressusingDate.now()+ ref; hook intoPressableviaonPress={debouncedOnPress}.- Minor typing adjustments for
PressableStateCallbackTypeon web.- Examples:
- Revamp
example/src/Examples/TouchableRippleExample.tsxwith a scrollable demo showcasing basic ripple and a debounce test (normal vs debounced buttons, counters, reset).- Tests:
- Extend
src/components/__tests__/TouchableRipple.test.tsxto 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.
Hey @BohdanKhv, thank you for your pull request 🤗. The documentation from this branch can be viewed here.