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 useKeyedChildListeners() {\n var _React$useRef = React.useRef(Object.assign(Object.create(null), {\n getState: {},\n beforeRemove: {}\n })),\n keyedListeners = _React$useRef.current;\n var addKeyedListener = React.useCallback(function (type, key, listener) {\n keyedListeners[type][key] = listener;\n return function () {\n keyedListeners[type][key] = undefined;\n };\n }, [keyedListeners]);\n return {\n keyedListeners: keyedListeners,\n addKeyedListener: addKeyedListener\n };\n}","map":{"version":3,"sources":["useKeyedChildListeners.tsx"],"names":["React","useKeyedChildListeners","current","keyedListeners","useRef","Object","assign","create","getState","beforeRemove","addKeyedListener","useCallback","type","key","listener","undefined"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAO9B,eAAe,SAASC,sBAAsB,GAAG;EAC/C,oBAAoCD,KAAK,CAACI,MAAM,CAM9CC,MAAM,CAACC,MAAM,CAACD,MAAM,CAACE,MAAM,CAAC,IAAI,CAAC,EAAE;MACjCC,QAAQ,EAAE,CAAC,CAAC;MACZC,YAAY,EAAE,CAAC;IACjB,CAAC,CAAC,CACH;IAVgBN,cAAAA,iBAATD,OAAO;EAYf,IAAMQ,gBAAgB,GAAGV,KAAK,CAACW,WAAW,CACxC,UACEC,IAAO,EACPC,GAAW,EACXC,QAA6B,EAC1B;IAEHX,cAAc,CAACS,IAAI,CAAC,CAACC,GAAG,CAAC,GAAGC,QAAQ;IAEpC,OAAO,YAAM;MAEXX,cAAc,CAACS,IAAI,CAAC,CAACC,GAAG,CAAC,GAAGE,SAAS;IACvC,CAAC;EACH,CAAC,EACD,CAACZ,cAAc,CAAC,CACjB;EAED,OAAO;IACLA,cAAc,EAAdA,cAAc;IACdO,gBAAAA,EAAAA;EACF,CAAC;AACH","sourceRoot":"../../src","sourcesContent":["import * as React from 'react';\n/**\n * Hook which lets child navigators add getters to be called for obtaining rehydrated state.\n */\nexport default function useKeyedChildListeners() {\n const {\n current: keyedListeners\n } = React.useRef(Object.assign(Object.create(null), {\n getState: {},\n beforeRemove: {}\n }));\n const addKeyedListener = React.useCallback((type, key, listener) => {\n // @ts-expect-error: according to ref stated above you can use `key` to index type\n keyedListeners[type][key] = listener;\n return () => {\n // @ts-expect-error: according to ref stated above you can use `key` to index type\n keyedListeners[type][key] = undefined;\n };\n }, [keyedListeners]);\n return {\n keyedListeners,\n addKeyedListener\n };\n}\n//# sourceMappingURL=useKeyedChildListeners.js.map"]},"metadata":{},"sourceType":"module"}