File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 11import { useCallback , useMemo } from "react" ;
2+ import { Platform } from "react-native" ;
23import * as Haptics from "expo-haptics" ;
34
45type FeedbackType = "light" | "medium" | "heavy" | "selection" ;
56
67export 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 ) ;
You can’t perform that action at this time.
0 commit comments