UNPKG

1.83 kBSource Map (JSON)View Raw
1{"version":3,"names":["checkDuplicateRouteNames","state","duplicates","getRouteNames","location","routes","forEach","route","currentLocation","name","routeNames","routeName","push"],"sources":["checkDuplicateRouteNames.tsx"],"sourcesContent":["import type { NavigationState, PartialState } from '@react-navigation/routers';\n\nexport default function checkDuplicateRouteNames(state: NavigationState) {\n const duplicates: string[][] = [];\n\n const getRouteNames = (\n location: string,\n state: NavigationState | PartialState<NavigationState>\n ) => {\n state.routes.forEach((route: typeof state.routes[0]) => {\n const currentLocation = location\n ? `${location} > ${route.name}`\n : route.name;\n\n route.state?.routeNames?.forEach((routeName) => {\n if (routeName === route.name) {\n duplicates.push([\n currentLocation,\n `${currentLocation} > ${route.name}`,\n ]);\n }\n });\n\n if (route.state) {\n getRouteNames(currentLocation, route.state);\n }\n });\n };\n\n getRouteNames('', state);\n\n return duplicates;\n}\n"],"mappings":"AAEA,eAAe,SAASA,wBAAT,CAAkCC,KAAlC,EAA0D;EACvE,MAAMC,UAAsB,GAAG,EAA/B;;EAEA,MAAMC,aAAa,GAAG,CACpBC,QADoB,EAEpBH,KAFoB,KAGjB;IACHA,KAAK,CAACI,MAAN,CAAaC,OAAb,CAAsBC,KAAD,IAAmC;MAAA;;MACtD,MAAMC,eAAe,GAAGJ,QAAQ,GAC3B,GAAEA,QAAS,MAAKG,KAAK,CAACE,IAAK,EADA,GAE5BF,KAAK,CAACE,IAFV;MAIA,gBAAAF,KAAK,CAACN,KAAN,uFAAaS,UAAb,gFAAyBJ,OAAzB,CAAkCK,SAAD,IAAe;QAC9C,IAAIA,SAAS,KAAKJ,KAAK,CAACE,IAAxB,EAA8B;UAC5BP,UAAU,CAACU,IAAX,CAAgB,CACdJ,eADc,EAEb,GAAEA,eAAgB,MAAKD,KAAK,CAACE,IAAK,EAFrB,CAAhB;QAID;MACF,CAPD;;MASA,IAAIF,KAAK,CAACN,KAAV,EAAiB;QACfE,aAAa,CAACK,eAAD,EAAkBD,KAAK,CAACN,KAAxB,CAAb;MACD;IACF,CAjBD;EAkBD,CAtBD;;EAwBAE,aAAa,CAAC,EAAD,EAAKF,KAAL,CAAb;EAEA,OAAOC,UAAP;AACD"}
\No newline at end of file