Skip to content

Commit 7bd140f

Browse files
committed
fix(utils): 🚑 remove haptics case on web
1 parent 3b06103 commit 7bd140f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/utils/useHaptic.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import { useCallback, useMemo } from "react";
2+
import { Platform } from "react-native";
23
import * as Haptics from "expo-haptics";
34

45
type FeedbackType = "light" | "medium" | "heavy" | "selection";
56

67
export const useHaptic = (feedbackType: FeedbackType = "selection") => {
78
const createHapticHandler = useCallback(
89
(type: Haptics.ImpactFeedbackStyle) => {
9-
return () => Haptics.impactAsync(type);
10+
return Platform.OS === "web"
11+
? undefined
12+
: () => Haptics.impactAsync(type);
1013
},
1114
[],
1215
);
@@ -16,7 +19,7 @@ export const useHaptic = (feedbackType: FeedbackType = "selection") => {
1619
light: createHapticHandler(Haptics.ImpactFeedbackStyle.Light),
1720
medium: createHapticHandler(Haptics.ImpactFeedbackStyle.Medium),
1821
heavy: createHapticHandler(Haptics.ImpactFeedbackStyle.Heavy),
19-
selection: Haptics.selectionAsync,
22+
selection: Platform.OS === "web" ? undefined : Haptics.selectionAsync,
2023
}),
2124
[createHapticHandler],
2225
);

0 commit comments

Comments
 (0)