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.8 KiB
1 line
2.8 KiB
{"ast":null,"code":"import * as React from 'react';\nimport NavigationBuilderContext from \"./NavigationBuilderContext\";\nexport default function useOnRouteFocus(_ref) {\n var router = _ref.router,\n getState = _ref.getState,\n sourceRouteKey = _ref.key,\n setState = _ref.setState;\n var _React$useContext = React.useContext(NavigationBuilderContext),\n onRouteFocusParent = _React$useContext.onRouteFocus;\n return React.useCallback(function (key) {\n var state = getState();\n var result = router.getStateForRouteFocus(state, key);\n if (result !== state) {\n setState(result);\n }\n if (onRouteFocusParent !== undefined && sourceRouteKey !== undefined) {\n onRouteFocusParent(sourceRouteKey);\n }\n }, [getState, onRouteFocusParent, router, setState, sourceRouteKey]);\n}","map":{"version":3,"sources":["useOnRouteFocus.tsx"],"names":["React","NavigationBuilderContext","useOnRouteFocus","router","getState","key","sourceRouteKey","setState","onRouteFocus","onRouteFocusParent","useContext","useCallback","state","result","getStateForRouteFocus","undefined"],"mappings":"AAKA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B,OAAOC,wBAAwB;AAc/B,eAAe,SAASC,eAAe,CAAA,IAAA,EAKnB;EALqD,IACvEC,MAAM,GAIU,IAAA,CAJhBA,MAAM;IACNC,QAAQ,GAGQ,IAAA,CAHhBA,QAAQ;IACHE,cAAc,GAEH,IAAA,CAFhBD,GAAG;IACHE,QAAAA,GACgB,IAAA,CADhBA,QAAAA;EAEA,wBAA6CP,KAAK,CAACU,UAAU,CAC3DT,wBAAwB,CACzB;IAFqBQ,kBAAAA,qBAAdD,YAAY;EAIpB,OAAOR,KAAK,CAACW,WAAW,CACrBN,UAAAA,GAAW,EAAK;IACf,IAAMO,KAAK,GAAGR,QAAQ,EAAE;IACxB,IAAMS,MAAM,GAAGV,MAAM,CAACW,qBAAqB,CAACF,KAAK,EAAEP,GAAG,CAAC;IAEvD,IAAIQ,MAAM,KAAKD,KAAK,EAAE;MACpBL,QAAQ,CAACM,MAAM,CAAC;IAClB;IAEA,IAAIJ,kBAAkB,KAAKM,SAAS,IAAIT,cAAc,KAAKS,SAAS,EAAE;MACpEN,kBAAkB,CAACH,cAAc,CAAC;IACpC;EACF,CAAC,EACD,CAACF,QAAQ,EAAEK,kBAAkB,EAAEN,MAAM,EAAEI,QAAQ,EAAED,cAAc,CAAC,CACjE;AACH","sourceRoot":"../../src","sourcesContent":["import * as React from 'react';\nimport NavigationBuilderContext from './NavigationBuilderContext';\n/**\n * Hook to handle focus actions for a route.\n * Focus action needs to be treated specially, coz when a nested route is focused,\n * the parent navigators also needs to be focused.\n */\nexport default function useOnRouteFocus(_ref) {\n let {\n router,\n getState,\n key: sourceRouteKey,\n setState\n } = _ref;\n const {\n onRouteFocus: onRouteFocusParent\n } = React.useContext(NavigationBuilderContext);\n return React.useCallback(key => {\n const state = getState();\n const result = router.getStateForRouteFocus(state, key);\n if (result !== state) {\n setState(result);\n }\n if (onRouteFocusParent !== undefined && sourceRouteKey !== undefined) {\n onRouteFocusParent(sourceRouteKey);\n }\n }, [getState, onRouteFocusParent, router, setState, sourceRouteKey]);\n}\n//# sourceMappingURL=useOnRouteFocus.js.map"]},"metadata":{},"sourceType":"module"} |