import type { Route } from '@react-navigation/native'; import type { StackDescriptorMap } from '../types'; export const getModalRouteKeys = ( routes: Route[], descriptors: StackDescriptorMap ) => routes.reduce((acc, route) => { const { presentation } = descriptors[route.key]?.options ?? {}; if ( (acc.length && !presentation) || presentation === 'modal' || presentation === 'transparentModal' ) { acc.push(route.key); } return acc; }, []);