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
2.3 KiB

{"ast":null,"code":"import * as React from 'react';\nexport default function useChildListeners() {\n var _React$useRef = React.useRef({\n action: [],\n focus: []\n }),\n listeners = _React$useRef.current;\n var addListener = React.useCallback(function (type, listener) {\n listeners[type].push(listener);\n var removed = false;\n return function () {\n var index = listeners[type].indexOf(listener);\n if (!removed && index > -1) {\n removed = true;\n listeners[type].splice(index, 1);\n }\n };\n }, [listeners]);\n return {\n listeners: listeners,\n addListener: addListener\n };\n}","map":{"version":3,"sources":["useChildListeners.tsx"],"names":["React","useChildListeners","current","listeners","useRef","action","focus","addListener","useCallback","type","listener","push","removed","index","indexOf","splice"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAO9B,eAAe,SAASC,iBAAiB,GAAG;EAC1C,oBAA+BD,KAAK,CAACI,MAAM,CAExC;MACDC,MAAM,EAAE,EAAE;MACVC,KAAK,EAAE;IACT,CAAC,CAAC;IALeH,SAAAA,iBAATD,OAAO;EAOf,IAAMK,WAAW,GAAGP,KAAK,CAACQ,WAAW,CACnC,UAA8BC,IAAO,EAAEC,QAAwB,EAAK;IAClEP,SAAS,CAACM,IAAI,CAAC,CAACE,IAAI,CAACD,QAAQ,CAAC;IAE9B,IAAIE,OAAO,GAAG,KAAK;IACnB,OAAO,YAAM;MACX,IAAMC,KAAK,GAAGV,SAAS,CAACM,IAAI,CAAC,CAACK,OAAO,CAACJ,QAAQ,CAAC;MAE/C,IAAI,CAACE,OAAO,IAAIC,KAAK,GAAG,CAAC,CAAC,EAAE;QAC1BD,OAAO,GAAG,IAAI;QACdT,SAAS,CAACM,IAAI,CAAC,CAACM,MAAM,CAACF,KAAK,EAAE,CAAC,CAAC;MAClC;IACF,CAAC;EACH,CAAC,EACD,CAACV,SAAS,CAAC,CACZ;EAED,OAAO;IACLA,SAAS,EAATA,SAAS;IACTI,WAAAA,EAAAA;EACF,CAAC;AACH","sourceRoot":"../../src","sourcesContent":["import * as React from 'react';\n/**\n * Hook which lets child navigators add action listeners.\n */\nexport default function useChildListeners() {\n const {\n current: listeners\n } = React.useRef({\n action: [],\n focus: []\n });\n const addListener = React.useCallback((type, listener) => {\n listeners[type].push(listener);\n let removed = false;\n return () => {\n const index = listeners[type].indexOf(listener);\n if (!removed && index > -1) {\n removed = true;\n listeners[type].splice(index, 1);\n }\n };\n }, [listeners]);\n return {\n listeners,\n addListener\n };\n}\n//# sourceMappingURL=useChildListeners.js.map"]},"metadata":{},"sourceType":"module"}