5d0b9026cc6083a65a986e141642d440.json 3.6 KB

1
  1. {"ast":null,"code":"import { ReactReduxContext } from '../components/Context';\nimport { useStore as useDefaultStore, createStoreHook } from './useStore';\n/**\n * Hook factory, which creates a `useDispatch` hook bound to a given context.\n *\n * @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.\n * @returns {Function} A `useDispatch` hook bound to the specified context.\n */\n\nexport function createDispatchHook(context) {\n if (context === void 0) {\n context = ReactReduxContext;\n }\n\n var useStore = context === ReactReduxContext ? useDefaultStore : createStoreHook(context);\n return function useDispatch() {\n var store = useStore();\n return store.dispatch;\n };\n}\n/**\n * A hook to access the redux `dispatch` function.\n *\n * @returns {any|function} redux store's `dispatch` function\n *\n * @example\n *\n * import React, { useCallback } from 'react'\n * import { useDispatch } from 'react-redux'\n *\n * export const CounterComponent = ({ value }) => {\n * const dispatch = useDispatch()\n * const increaseCounter = useCallback(() => dispatch({ type: 'increase-counter' }), [])\n * return (\n * <div>\n * <span>{value}</span>\n * <button onClick={increaseCounter}>Increase counter</button>\n * </div>\n * )\n * }\n */\n\nexport var useDispatch = /*#__PURE__*/createDispatchHook();","map":{"version":3,"sources":["/home/ilya/projects/NIX/homework/react-store/node_modules/react-redux/es/hooks/useDispatch.js"],"names":["ReactReduxContext","useStore","useDefaultStore","createStoreHook","createDispatchHook","context","useDispatch","store","dispatch"],"mappings":"AAAA,SAASA,iBAAT,QAAkC,uBAAlC;AACA,SAASC,QAAQ,IAAIC,eAArB,EAAsCC,eAAtC,QAA6D,YAA7D;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,SAASC,kBAAT,CAA4BC,OAA5B,EAAqC;AAC1C,MAAIA,OAAO,KAAK,KAAK,CAArB,EAAwB;AACtBA,IAAAA,OAAO,GAAGL,iBAAV;AACD;;AAED,MAAIC,QAAQ,GAAGI,OAAO,KAAKL,iBAAZ,GAAgCE,eAAhC,GAAkDC,eAAe,CAACE,OAAD,CAAhF;AACA,SAAO,SAASC,WAAT,GAAuB;AAC5B,QAAIC,KAAK,GAAGN,QAAQ,EAApB;AACA,WAAOM,KAAK,CAACC,QAAb;AACD,GAHD;AAID;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,IAAIF,WAAW,GAAG,aAAaF,kBAAkB,EAAjD","sourcesContent":["import { ReactReduxContext } from '../components/Context';\nimport { useStore as useDefaultStore, createStoreHook } from './useStore';\n/**\n * Hook factory, which creates a `useDispatch` hook bound to a given context.\n *\n * @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.\n * @returns {Function} A `useDispatch` hook bound to the specified context.\n */\n\nexport function createDispatchHook(context) {\n if (context === void 0) {\n context = ReactReduxContext;\n }\n\n var useStore = context === ReactReduxContext ? useDefaultStore : createStoreHook(context);\n return function useDispatch() {\n var store = useStore();\n return store.dispatch;\n };\n}\n/**\n * A hook to access the redux `dispatch` function.\n *\n * @returns {any|function} redux store's `dispatch` function\n *\n * @example\n *\n * import React, { useCallback } from 'react'\n * import { useDispatch } from 'react-redux'\n *\n * export const CounterComponent = ({ value }) => {\n * const dispatch = useDispatch()\n * const increaseCounter = useCallback(() => dispatch({ type: 'increase-counter' }), [])\n * return (\n * <div>\n * <span>{value}</span>\n * <button onClick={increaseCounter}>Increase counter</button>\n * </div>\n * )\n * }\n */\n\nexport var useDispatch = /*#__PURE__*/createDispatchHook();"]},"metadata":{},"sourceType":"module"}