UNPKG

custom-app

Version:

ITIMS��Ʒ�鿪��ר��React���,�Dz��ý��ּ�dhcc-app���������

34 lines (31 loc) 947 B
"use strict"; exports.__esModule = true; exports.useDispatch = useDispatch; var _useStore = require("./useStore"); /** * A hook to access the redux `dispatch` function. Note that in most cases where you * might want to use this hook it is recommended to use `useActions` instead to bind * action creators to the `dispatch` function. * * @returns {any|function} redux store's `dispatch` function * * @example * * import React, { useCallback } from 'react' * import { useReduxDispatch } from 'react-redux' * * export const CounterComponent = ({ value }) => { * const dispatch = useDispatch() * const increaseCounter = useCallback(() => dispatch({ type: 'increase-counter' }), []) * return ( * <div> * <span>{value}</span> * <button onClick={increaseCounter}>Increase counter</button> * </div> * ) * } */ function useDispatch() { var store = (0, _useStore.useStore)(); return store.dispatch; }