Skip to content

Commit

Permalink
fix: fixes BottomSheetBackdrop defaults
Browse files Browse the repository at this point in the history
Coercion of 0 and false result in defaults being accidentally assigned
to the BottomSheetBackdrop's props. This fix uses the null coalesce
operator ?? to use either a user supplied value or fall back to the
built-in default.

Resolves gorhom#779
  • Loading branch information
jakobo committed Dec 23, 2021
1 parent 8d9b050 commit 1147a59
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/components/bottomSheetBackdrop/BottomSheetBackdrop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import type { BottomSheetDefaultBackdropProps } from './types';

const BottomSheetBackdropComponent = ({
animatedIndex,
opacity = DEFAULT_OPACITY,
appearsOnIndex = DEFAULT_APPEARS_ON_INDEX,
disappearsOnIndex = DEFAULT_DISAPPEARS_ON_INDEX,
enableTouchThrough = DEFAULT_ENABLE_TOUCH_THROUGH,
opacity: userOpacity,
appearsOnIndex: userAppearsOnIndex,
disappearsOnIndex: userDisappearsOnIndex,
enableTouchThrough: userEnableTouchThrough,
pressBehavior = DEFAULT_PRESS_BEHAVIOR,
style,
children,
Expand All @@ -36,6 +36,15 @@ const BottomSheetBackdropComponent = ({
const { snapToIndex, close } = useBottomSheet();
//#endregion

//#region defaults
const opacity = userOpacity ?? DEFAULT_OPACITY;
const appearsOnIndex = userAppearsOnIndex ?? DEFAULT_APPEARS_ON_INDEX;
const disappearsOnIndex =
userDisappearsOnIndex ?? DEFAULT_DISAPPEARS_ON_INDEX;
const enableTouchThrough =
userEnableTouchThrough ?? DEFAULT_ENABLE_TOUCH_THROUGH;
//#endregion

//#region variables
const containerRef = useRef<Animated.View>(null);
const pointerEvents = enableTouchThrough ? 'none' : 'auto';
Expand Down

0 comments on commit 1147a59

Please sign in to comment.