Skip to content

Commit ac03ad5

Browse files
committed
fix(components): 🚑 add conditional call by checking if the haptics function is available
1 parent 7bd140f commit ac03ad5

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

src/components/button/Button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ const RNButton: React.FC<Partial<ButtonProps>> = forwardRef<
137137

138138
const handlePress = useCallback((event: GestureResponderEvent) => {
139139
onPress && onPress(event);
140-
hapticEnabled && hapticMedium();
140+
hapticEnabled && hapticMedium?.();
141141
// eslint-disable-next-line react-hooks/exhaustive-deps
142142
}, []);
143143

src/components/checkbox/Checkbox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ const RNCheckbox: React.FC<Partial<CheckboxProps>> = forwardRef<
178178
}, [checkboxToggleState.isSelected, isIndeterminate]);
179179

180180
const handleChange = useCallback(() => {
181-
hapticEnabled && hapticSelection();
181+
hapticEnabled && hapticSelection?.();
182182
if (checkboxGroupState) {
183183
if (props.value) {
184184
if (checkboxToggleState.isSelected) {

src/components/radio/Radio.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ const RNRadio: React.FC<Partial<RadioProps>> = forwardRef<
111111
}, [index, props?.value, selectedValue, setFocusableIndex]);
112112

113113
const handleChange = useCallback(() => {
114-
hapticEnabled && hapticSelection();
114+
hapticEnabled && hapticSelection?.();
115115
// @ts-ignore
116116
setSelectedValue(props?.value);
117117
setFocusableIndex(index as number);

src/components/switch/Switch.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ const RNSwitch: React.FC<Partial<SwitchProps>> = forwardRef<
291291
thumbAnimated.value = withSpring(1, SPRING_CONFIG);
292292
}
293293
runOnJS(setSwitchState)(!switchState);
294-
hapticEnabled && runOnJS(hapticSelection)();
294+
hapticEnabled && hapticSelection && runOnJS(hapticSelection)();
295295
})
296296
.onTouchesCancelled(() => {
297297
if (switchState) {

src/components/tag/Tag.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const RNTag: React.FC<Partial<TagProps>> = forwardRef<
108108

109109
const handlePress = useCallback((event: GestureResponderEvent) => {
110110
onPress && onPress(event);
111-
hapticEnabled && hapticSelection();
111+
hapticEnabled && hapticSelection?.();
112112
// eslint-disable-next-line react-hooks/exhaustive-deps
113113
}, []);
114114

0 commit comments

Comments
 (0)