UNPKG

1.61 kBSource Map (JSON)View Raw
1{"version":3,"names":["React","CurrentRenderContext","useCurrentRender","state","navigation","descriptors","current","useContext","isFocused","options","routes","index","key"],"sources":["useCurrentRender.tsx"],"sourcesContent":["import type { NavigationState, ParamListBase } from '@react-navigation/routers';\nimport * as React from 'react';\n\nimport CurrentRenderContext from './CurrentRenderContext';\nimport type {\n Descriptor,\n NavigationHelpers,\n NavigationProp,\n RouteProp,\n} from './types';\n\ntype Options = {\n state: NavigationState;\n navigation: NavigationHelpers<ParamListBase>;\n descriptors: Record<\n string,\n Descriptor<object, NavigationProp<ParamListBase>, RouteProp<ParamListBase>>\n >;\n};\n\n/**\n * Write the current options, so that server renderer can get current values\n * Mutating values like this is not safe in async mode, but it doesn't apply to SSR\n */\nexport default function useCurrentRender({\n state,\n navigation,\n descriptors,\n}: Options) {\n const current = React.useContext(CurrentRenderContext);\n\n if (current && navigation.isFocused()) {\n current.options = descriptors[state.routes[state.index].key].options;\n }\n}\n"],"mappings":"AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,OAAOC,oBAAP,MAAiC,wBAAjC;;AAiBA;AACA;AACA;AACA;AACA,eAAe,SAASC,gBAAT,OAIH;EAAA,IAJ6B;IACvCC,KADuC;IAEvCC,UAFuC;IAGvCC;EAHuC,CAI7B;EACV,MAAMC,OAAO,GAAGN,KAAK,CAACO,UAAN,CAAiBN,oBAAjB,CAAhB;;EAEA,IAAIK,OAAO,IAAIF,UAAU,CAACI,SAAX,EAAf,EAAuC;IACrCF,OAAO,CAACG,OAAR,GAAkBJ,WAAW,CAACF,KAAK,CAACO,MAAN,CAAaP,KAAK,CAACQ,KAAnB,EAA0BC,GAA3B,CAAX,CAA2CH,OAA7D;EACD;AACF"}
\No newline at end of file