Skip to content

Commit

Permalink
fix(components): 🚑 add conditional call by checking if the haptics fu…
Browse files Browse the repository at this point in the history
…nction is available
  • Loading branch information
Karthik-B-06 authored and crstnmac committed Jan 12, 2023
1 parent 469b71f commit 1e39fb8
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const RNButton: React.FC<Partial<ButtonProps>> = forwardRef<

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

Expand Down
2 changes: 1 addition & 1 deletion src/components/checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const RNCheckbox: React.FC<Partial<CheckboxProps>> = forwardRef<
}, [checkboxToggleState.isSelected, isIndeterminate]);

const handleChange = useCallback(() => {
hapticEnabled && hapticSelection();
hapticEnabled && hapticSelection?.();
if (checkboxGroupState) {
if (props.value) {
if (checkboxToggleState.isSelected) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/radio/Radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const RNRadio: React.FC<Partial<RadioProps>> = forwardRef<
}, [index, props?.value, selectedValue, setFocusableIndex]);

const handleChange = useCallback(() => {
hapticEnabled && hapticSelection();
hapticEnabled && hapticSelection?.();
// @ts-ignore
setSelectedValue(props?.value);
setFocusableIndex(index as number);
Expand Down
2 changes: 1 addition & 1 deletion src/components/switch/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ const RNSwitch: React.FC<Partial<SwitchProps>> = forwardRef<
thumbAnimated.value = withSpring(1, SPRING_CONFIG);
}
runOnJS(setSwitchState)(!switchState);
hapticEnabled && runOnJS(hapticSelection)();
hapticEnabled && hapticSelection && runOnJS(hapticSelection)();
})
.onTouchesCancelled(() => {
if (switchState) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/tag/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const RNTag: React.FC<Partial<TagProps>> = forwardRef<

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

Expand Down

0 comments on commit 1e39fb8

Please sign in to comment.