Skip to content

Commit 02f0d6e

Browse files
committed
change to expo-haptics
1 parent 1673e77 commit 02f0d6e

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"react-native": "*",
4646
"react-native-svg": ">=7.0.0<10",
4747
"react-native-gesture-handler": ">1.1.0<2",
48-
"react-native-haptic-feedback": "^1.8.0"
48+
"expo-haptics": "^8.0.0"
4949
},
5050
"devDependencies": {
5151
"@babel/core": "^7.7.7",

src/lib/SlideBarChart.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Component } from 'react'
22
import { View, StyleSheet, Animated, TextInput, TouchableWithoutFeedback } from 'react-native'
3-
import { isAndroid, vw, reactNativeHapticFeedbackIOS } from './utils/platform'
3+
import { isAndroid, vw, reactNativeHapticSelectionIOS } from './utils/platform'
44
import ToolTip from './components/toolTip/ToolTip'
55
import { scaleTime, scaleLinear, ScaleTime, ScaleLinear } from 'd3-scale'
66
import Cursor from './components/Cursor/Cursor'
@@ -312,7 +312,7 @@ class SlideBarChart extends Component<SlideBarChartComponentProps, State> {
312312
return
313313
}
314314
if (isTouch && hapticFeedback) {
315-
reactNativeHapticFeedbackIOS('selection')
315+
reactNativeHapticSelectionIOS()
316316
}
317317
this.setState({ selectedBarNumber: this.selectedBarNumber })
318318
const barWidthForToolTip = barWidth ??

src/lib/utils/platform.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { Platform, Dimensions } from 'react-native'
2-
import ReactNativeHapticFeedback, {
3-
HapticFeedbackTypes,
4-
} from 'react-native-haptic-feedback'
2+
import * as Haptics from 'expo-haptics'
53

64
export const isAndroid = () => {
75
return Platform.OS === 'android'
@@ -19,15 +17,8 @@ export const vw = (
1917
return rounded ? Math.round(value) : value
2018
}
2119

22-
export const hapticFeedbackOptions = {
23-
enableVibrateFallback: false,
24-
ignoreAndroidSystemSettings: false,
25-
}
26-
27-
export const reactNativeHapticFeedbackIOS = (
28-
impactType: HapticFeedbackTypes
29-
) => {
20+
export const reactNativeHapticSelectionIOS = () => {
3021
if (isIOS()) {
31-
ReactNativeHapticFeedback.trigger(impactType, hapticFeedbackOptions)
22+
Haptics.selectionAsync()
3223
}
3324
}

0 commit comments

Comments
 (0)