You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
3.7 KiB
1 line
3.7 KiB
{"ast":null,"code":"import * as React from 'react';\nvar MULTIPLE_NAVIGATOR_ERROR = \"Another navigator is already registered for this container. You likely have multiple navigators under a single \\\"NavigationContainer\\\" or \\\"Screen\\\". Make sure each navigator is under a separate \\\"Screen\\\" container. See https://reactnavigation.org/docs/nesting-navigators for a guide on nesting.\";\nexport var SingleNavigatorContext = React.createContext(undefined);\nexport default function EnsureSingleNavigator(_ref) {\n var children = _ref.children;\n var navigatorKeyRef = React.useRef();\n var value = React.useMemo(function () {\n return {\n register: function register(key) {\n var currentKey = navigatorKeyRef.current;\n if (currentKey !== undefined && key !== currentKey) {\n throw new Error(MULTIPLE_NAVIGATOR_ERROR);\n }\n navigatorKeyRef.current = key;\n },\n unregister: function unregister(key) {\n var currentKey = navigatorKeyRef.current;\n if (key !== currentKey) {\n return;\n }\n navigatorKeyRef.current = undefined;\n }\n };\n }, []);\n return React.createElement(SingleNavigatorContext.Provider, {\n value: value\n }, children);\n}","map":{"version":3,"sources":["EnsureSingleNavigator.tsx"],"names":["React","MULTIPLE_NAVIGATOR_ERROR","SingleNavigatorContext","createContext","undefined","EnsureSingleNavigator","children","navigatorKeyRef","useRef","value","useMemo","register","key","currentKey","current","Error","unregister"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAM9B,IAAMC,wBAAwB,6SAAuS;AAErU,OAAO,IAAMC,sBAAsB,GAAGF,KAAK,CAACG,aAAa,CAMvDC,SAAS,CAAC;AAKZ,eAAe,SAASC,qBAAqB,CAAA,IAAA,EAAsB;EAArB,IAAEC,QAAAA,GAAiB,IAAA,CAAjBA,QAAAA;EAC9C,IAAMC,eAAe,GAAGP,KAAK,CAACQ,MAAM,EAAsB;EAE1D,IAAMC,KAAK,GAAGT,KAAK,CAACU,OAAO,CACzB;IAAA,OAAO;MACLC,QAAQ,oBAACC,GAAW,EAAE;QACpB,IAAMC,UAAU,GAAGN,eAAe,CAACO,OAAO;QAE1C,IAAID,UAAU,KAAKT,SAAS,IAAIQ,GAAG,KAAKC,UAAU,EAAE;UAClD,MAAM,IAAIE,KAAK,CAACd,wBAAwB,CAAC;QAC3C;QAEAM,eAAe,CAACO,OAAO,GAAGF,GAAG;MAC/B,CAAC;MACDI,UAAU,sBAACJ,GAAW,EAAE;QACtB,IAAMC,UAAU,GAAGN,eAAe,CAACO,OAAO;QAE1C,IAAIF,GAAG,KAAKC,UAAU,EAAE;UACtB;QACF;QAEAN,eAAe,CAACO,OAAO,GAAGV,SAAS;MACrC;IACF,CAAC;EAAA,CAAC,EACF,EAAE,CACH;EAED,OACE,KAAA,CAAA,aAAA,CAAC,sBAAsB,CAAC,QAAQ,EAAA;IAAC,KAAK,EAAEK;EAAM,CAAA,EAC3CH,QAAQ,CACuB;AAEtC","sourceRoot":"../../src","sourcesContent":["import * as React from 'react';\nconst MULTIPLE_NAVIGATOR_ERROR = `Another navigator is already registered for this container. You likely have multiple navigators under a single \"NavigationContainer\" or \"Screen\". Make sure each navigator is under a separate \"Screen\" container. See https://reactnavigation.org/docs/nesting-navigators for a guide on nesting.`;\nexport const SingleNavigatorContext = /*#__PURE__*/React.createContext(undefined);\n\n/**\n * Component which ensures that there's only one navigator nested under it.\n */\nexport default function EnsureSingleNavigator(_ref) {\n let {\n children\n } = _ref;\n const navigatorKeyRef = React.useRef();\n const value = React.useMemo(() => ({\n register(key) {\n const currentKey = navigatorKeyRef.current;\n if (currentKey !== undefined && key !== currentKey) {\n throw new Error(MULTIPLE_NAVIGATOR_ERROR);\n }\n navigatorKeyRef.current = key;\n },\n unregister(key) {\n const currentKey = navigatorKeyRef.current;\n if (key !== currentKey) {\n return;\n }\n navigatorKeyRef.current = undefined;\n }\n }), []);\n return /*#__PURE__*/React.createElement(SingleNavigatorContext.Provider, {\n value: value\n }, children);\n}\n//# sourceMappingURL=EnsureSingleNavigator.js.map"]},"metadata":{},"sourceType":"module"} |