$ show mkuczera/react-native-haptic-feedback
react-native-haptic-feedback is a React Native library providing comprehensive haptic feedback capabilities for iOS and Android. It implements a dual-tier fallback chain on both platforms: iOS uses Core Haptics (CHHapticEngine) with UIKit generator fallback, while Android uses View.performHapticFeedback constants and VibrationEffect API. The library offers both simple trigger methods and complex pattern-based haptic sequences, includes cross-platform AHAP file playback with Android fallbacks, and provides React-first APIs like the useHaptics hook and TouchableHaptic component. Architecture features platform-specific native modules bridged via React Native's TurboModule system, with TypeScript source and auto-linking support.
The LLM identified 2 files worth highlighting for reuse:
Implements a compact notation system (oO.O) for defining haptic patterns. Converts strings to HapticEvent arrays with runtime and compile-time validation via TypeScript conditional types. Demonstrates advanced type system usage for DSL creation and could be extracted to any JS/TS project needing similar pattern parsing.
Custom React hook providing haptic methods with stable references through useMemo. Properly merges default and per-call options while maintaining referential equality. Exemplifies React best practices for wrapping native modules with dependency management and could serve as a template for similar native bridge abstractions.