UNPKG

1.76 kBSource Map (JSON)View Raw
1{"version":3,"names":["nanoid","React","SingleNavigatorContext","useRegisterNavigator","key","useState","container","useContext","undefined","Error","useEffect","register","unregister"],"sources":["useRegisterNavigator.tsx"],"sourcesContent":["import { nanoid } from 'nanoid/non-secure';\nimport * as React from 'react';\n\nimport { SingleNavigatorContext } from './EnsureSingleNavigator';\n\n/**\n * Register a navigator in the parent context (either a navigation container or a screen).\n * This is used to prevent multiple navigators under a single container or screen.\n */\nexport default function useRegisterNavigator() {\n const [key] = React.useState(() => nanoid());\n const container = React.useContext(SingleNavigatorContext);\n\n if (container === undefined) {\n throw new Error(\n \"Couldn't register the navigator. Have you wrapped your app with 'NavigationContainer'?\\n\\nThis can also happen if there are multiple copies of '@react-navigation' packages installed.\"\n );\n }\n\n React.useEffect(() => {\n const { register, unregister } = container;\n\n register(key);\n\n return () => unregister(key);\n }, [container, key]);\n\n return key;\n}\n"],"mappings":"AAAA,SAASA,MAAT,QAAuB,mBAAvB;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AAEA,SAASC,sBAAT,QAAuC,yBAAvC;AAEA;AACA;AACA;AACA;;AACA,eAAe,SAASC,oBAAT,GAAgC;EAC7C,MAAM,CAACC,GAAD,IAAQH,KAAK,CAACI,QAAN,CAAe,MAAML,MAAM,EAA3B,CAAd;EACA,MAAMM,SAAS,GAAGL,KAAK,CAACM,UAAN,CAAiBL,sBAAjB,CAAlB;;EAEA,IAAII,SAAS,KAAKE,SAAlB,EAA6B;IAC3B,MAAM,IAAIC,KAAJ,CACJ,wLADI,CAAN;EAGD;;EAEDR,KAAK,CAACS,SAAN,CAAgB,MAAM;IACpB,MAAM;MAAEC,QAAF;MAAYC;IAAZ,IAA2BN,SAAjC;IAEAK,QAAQ,CAACP,GAAD,CAAR;IAEA,OAAO,MAAMQ,UAAU,CAACR,GAAD,CAAvB;EACD,CAND,EAMG,CAACE,SAAD,EAAYF,GAAZ,CANH;EAQA,OAAOA,GAAP;AACD"}
\No newline at end of file