UNPKG

1.91 kBSource Map (JSON)View Raw
1{"version":3,"names":["CHILD_STATE","getFocusedRouteNameFromRoute","route","state","params","routeName","routes","index","type","length","name","screen","undefined"],"sources":["getFocusedRouteNameFromRoute.tsx"],"sourcesContent":["import type { Route } from '@react-navigation/routers';\n\nimport { CHILD_STATE } from './useRouteCache';\n\nexport default function getFocusedRouteNameFromRoute(\n route: Partial<Route<string>>\n): string | undefined {\n // @ts-expect-error: this isn't in type definitions coz we want this private\n const state = route[CHILD_STATE] ?? route.state;\n const params = route.params as { screen?: unknown } | undefined;\n\n const routeName = state\n ? // Get the currently active route name in the nested navigator\n state.routes[\n // If we have a partial state without index, for tab/drawer, first screen will be focused one, and last for stack\n // The type property will only exist for rehydrated state and not for state from deep link\n state.index ??\n (typeof state.type === 'string' && state.type !== 'stack'\n ? 0\n : state.routes.length - 1)\n ].name\n : // If state doesn't exist, we need to default to `screen` param if available\n typeof params?.screen === 'string'\n ? params.screen\n : undefined;\n\n return routeName;\n}\n"],"mappings":"AAEA,SAASA,WAAT,QAA4B,iBAA5B;AAEA,eAAe,SAASC,4BAAT,CACbC,KADa,EAEO;EAAA;;EACpB;EACA,MAAMC,KAAK,yBAAGD,KAAK,CAACF,WAAD,CAAR,mEAAyBE,KAAK,CAACC,KAA1C;EACA,MAAMC,MAAM,GAAGF,KAAK,CAACE,MAArB;EAEA,MAAMC,SAAS,GAAGF,KAAK,GACnB;EACAA,KAAK,CAACG,MAAN,CACE;EACA;EAFF,gBAGEH,KAAK,CAACI,KAHR,uDAIK,OAAOJ,KAAK,CAACK,IAAb,KAAsB,QAAtB,IAAkCL,KAAK,CAACK,IAAN,KAAe,OAAjD,GACG,CADH,GAEGL,KAAK,CAACG,MAAN,CAAaG,MAAb,GAAsB,CAN9B,EAOEC,IATiB,GAUnB;EACF,QAAON,MAAP,aAAOA,MAAP,uBAAOA,MAAM,CAAEO,MAAf,MAA0B,QAA1B,GACEP,MAAM,CAACO,MADT,GAEEC,SAbJ;EAeA,OAAOP,SAAP;AACD"}
\No newline at end of file