UNPKG

1.57 kBSource Map (JSON)View Raw
1{"version":3,"names":["useCurrentRender","state","navigation","descriptors","current","React","useContext","CurrentRenderContext","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;;AAEA;;;;;;;;AAiBA;AACA;AACA;AACA;AACe,SAASA,gBAAT,OAIH;EAAA,IAJ6B;IACvCC,KADuC;IAEvCC,UAFuC;IAGvCC;EAHuC,CAI7B;EACV,MAAMC,OAAO,GAAGC,KAAK,CAACC,UAAN,CAAiBC,6BAAjB,CAAhB;;EAEA,IAAIH,OAAO,IAAIF,UAAU,CAACM,SAAX,EAAf,EAAuC;IACrCJ,OAAO,CAACK,OAAR,GAAkBN,WAAW,CAACF,KAAK,CAACS,MAAN,CAAaT,KAAK,CAACU,KAAnB,EAA0BC,GAA3B,CAAX,CAA2CH,OAA7D;EACD;AACF"}
\No newline at end of file