Skip to content

Commit e211e8a

Browse files
committed
fix: Stop web from attempting to use native haptics module
1 parent a750b05 commit e211e8a

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

app/modules/native-crypto/src/ReactNativeHapticsModule.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
import { NativeModule, requireNativeModule } from 'expo';
2+
import { Platform, Vibration } from 'react-native';
23

34
declare class ReactNativeHapticsModule extends NativeModule {
45
triggerSlowRiseHaptic(): void;
56
triggerClickHaptic(): void;
67
cancelHaptic(): void;
78
}
89

9-
const module = requireNativeModule<ReactNativeHapticsModule>('LiftLogHaptics');
10+
const module =
11+
Platform.OS === 'web'
12+
? {
13+
triggerClickHaptic() {
14+
try {
15+
Vibration.vibrate(50);
16+
} catch {}
17+
},
18+
triggerSlowRiseHaptic() {},
19+
cancelHaptic() {},
20+
}
21+
: requireNativeModule<ReactNativeHapticsModule>('LiftLogHaptics');
1022

1123
export const triggerSlowRiseHaptic = () => {
1224
module.triggerSlowRiseHaptic();

0 commit comments

Comments
 (0)