diff --git a/example/src/screens/advanced/BackdropExample.tsx b/example/src/screens/advanced/BackdropExample.tsx index 45039012c..3b4d95363 100644 --- a/example/src/screens/advanced/BackdropExample.tsx +++ b/example/src/screens/advanced/BackdropExample.tsx @@ -7,8 +7,9 @@ import HeaderHandle from '../../components/headerHandle'; const BackdropExample = () => { // state - const [backdropPressBehavior, setBackdropPressBehavior] = - useState<'none' | 'close' | 'collapse'>('collapse'); + const [backdropPressBehavior, setBackdropPressBehavior] = useState< + 'none' | 'close' | 'collapse' + >('collapse'); // hooks const bottomSheetRef = useRef(null); diff --git a/src/components/bottomSheetBackdrop/BottomSheetBackdrop.tsx b/src/components/bottomSheetBackdrop/BottomSheetBackdrop.tsx index 69db94673..2446c1df9 100644 --- a/src/components/bottomSheetBackdrop/BottomSheetBackdrop.tsx +++ b/src/components/bottomSheetBackdrop/BottomSheetBackdrop.tsx @@ -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: _providedOpacity, + appearsOnIndex: _providedAppearsOnIndex, + disappearsOnIndex: _providedDisappearsOnIndex, + enableTouchThrough: _providedEnableTouchThrough, pressBehavior = DEFAULT_PRESS_BEHAVIOR, style, children, @@ -36,6 +36,15 @@ const BottomSheetBackdropComponent = ({ const { snapToIndex, close } = useBottomSheet(); //#endregion + //#region defaults + const opacity = _providedOpacity ?? DEFAULT_OPACITY; + const appearsOnIndex = _providedAppearsOnIndex ?? DEFAULT_APPEARS_ON_INDEX; + const disappearsOnIndex = + _providedDisappearsOnIndex ?? DEFAULT_DISAPPEARS_ON_INDEX; + const enableTouchThrough = + _providedEnableTouchThrough ?? DEFAULT_ENABLE_TOUCH_THROUGH; + //#endregion + //#region variables const containerRef = useRef(null); const pointerEvents = enableTouchThrough ? 'none' : 'auto'; diff --git a/src/components/bottomSheetBackdrop/types.d.ts b/src/components/bottomSheetBackdrop/types.d.ts index 0ebbbf48c..75268ee7c 100644 --- a/src/components/bottomSheetBackdrop/types.d.ts +++ b/src/components/bottomSheetBackdrop/types.d.ts @@ -1,3 +1,4 @@ +import { ReactNode } from 'react'; import type { ViewProps } from 'react-native'; import type { BottomSheetVariables } from '../../types'; @@ -42,5 +43,5 @@ export interface BottomSheetDefaultBackdropProps /** * Child component that will be rendered on backdrop. */ - children?: React.ReactNode | React.ReactNode[]; + children?: ReactNode | ReactNode[]; } diff --git a/src/contexts/external.ts b/src/contexts/external.ts index 3b3ec6d2b..2e1b84958 100644 --- a/src/contexts/external.ts +++ b/src/contexts/external.ts @@ -1,7 +1,8 @@ import { createContext } from 'react'; import type { BottomSheetMethods, BottomSheetVariables } from '../types'; -export const BottomSheetContext = - createContext<(BottomSheetMethods & BottomSheetVariables) | null>(null); +export const BottomSheetContext = createContext< + (BottomSheetMethods & BottomSheetVariables) | null +>(null); export const BottomSheetProvider = BottomSheetContext.Provider;