UNPKG

1.59 kBSource Map (JSON)View Raw
1{"version":3,"sources":["useCurrentRender.tsx"],"names":["useCurrentRender","state","navigation","descriptors","current","React","useContext","CurrentRenderContext","isFocused","options","routes","index","key"],"mappings":";;;;;;;AACA;;AAEA;;;;;;;;AAiBA;AACA;AACA;AACA;AACe,SAASA,gBAAT,OAIH;AAAA,MAJ6B;AACvCC,IAAAA,KADuC;AAEvCC,IAAAA,UAFuC;AAGvCC,IAAAA;AAHuC,GAI7B;AACV,QAAMC,OAAO,GAAGC,KAAK,CAACC,UAAN,CAAiBC,6BAAjB,CAAhB;;AAEA,MAAIH,OAAO,IAAIF,UAAU,CAACM,SAAX,EAAf,EAAuC;AACrCJ,IAAAA,OAAO,CAACK,OAAR,GAAkBN,WAAW,CAACF,KAAK,CAACS,MAAN,CAAaT,KAAK,CAACU,KAAnB,EAA0BC,GAA3B,CAAX,CAA2CH,OAA7D;AACD;AACF","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"]}
\No newline at end of file