import { useContext } from 'react'; import { ParamListBase, useNavigation } from '@react-navigation/native'; import { BottomSheetNavigatorContext, BottomSheetNavigatorContextType, } from '../contexts/internal'; import type { BottomSheetNavigationProp } from '../types'; export const useBottomSheetNavigator = < ParamList extends ParamListBase >(): BottomSheetNavigationProp & BottomSheetNavigatorContextType => { const navigationContext = useNavigation>(); const context = useContext(BottomSheetNavigatorContext); if (context === null) { throw new Error('BottomSheetNavigatorContext cannot be null.'); } return { ...context, ...navigationContext, }; };