diff --git a/src/alternate-renderers.js b/src/alternate-renderers.js index 7bfa04e50..592eb3f41 100644 --- a/src/alternate-renderers.js +++ b/src/alternate-renderers.js @@ -5,7 +5,6 @@ import connect from './connect/connect' import { useActions } from './hooks/useActions' import { useDispatch } from './hooks/useDispatch' -import { useRedux } from './hooks/useRedux' import { useSelector } from './hooks/useSelector' import { useStore } from './hooks/useStore' @@ -22,7 +21,6 @@ export { batch, useActions, useDispatch, - useRedux, useSelector, useStore } diff --git a/src/hooks/useRedux.js b/src/hooks/useRedux.js deleted file mode 100644 index 293abc8c3..000000000 --- a/src/hooks/useRedux.js +++ /dev/null @@ -1,43 +0,0 @@ -import { useSelector } from './useSelector' -import { useActions } from './useActions' - -/** - * A hook to access the redux store's state and to bind action creators to - * the store's dispatch function. In essence, this hook is a combination of - * `useSelector` and `useActions`. - * - * Note that this hook does currently not allow to pass a dependencies array, - * so the passed selector and any created callbacks are not memoized. If you - * require memoization, please use `useActions` and `useSelector`. - * - * @param {Function} selector the selector function - * @param {Function|Function[]|Object.} actions the action creators to bind - * - * @returns {[any, any]} a tuple of the selected state and the bound action creators - * - * @example - * - * import React from 'react' - * import { useRedux } from 'react-redux' - * import { RootState } from './store' - * - * export const CounterComponent = () => { - * const [counter, { inc1, inc }] = useRedux(state => state.counter, { - * inc1: () => ({ type: 'inc1' }), - * inc: amount => ({ type: 'inc', amount }), - * }) - * - * return ( - * <> - *
- * {counter} - *
- * - * - * - * ) - * } - */ -export function useRedux(selector, actions) { - return [useSelector(selector), useActions(actions)] -} diff --git a/src/index.js b/src/index.js index 3431cb6b3..10b168806 100644 --- a/src/index.js +++ b/src/index.js @@ -5,7 +5,6 @@ import connect from './connect/connect' import { useActions } from './hooks/useActions' import { useDispatch } from './hooks/useDispatch' -import { useRedux } from './hooks/useRedux' import { useSelector } from './hooks/useSelector' import { useStore } from './hooks/useStore' @@ -22,7 +21,6 @@ export { batch, useActions, useDispatch, - useRedux, useSelector, useStore } diff --git a/test/hooks/useRedux.spec.js b/test/hooks/useRedux.spec.js deleted file mode 100644 index 53b272ee3..000000000 --- a/test/hooks/useRedux.spec.js +++ /dev/null @@ -1,40 +0,0 @@ -/*eslint-disable react/prop-types*/ - -import React from 'react' -import { createStore } from 'redux' -import { renderHook, act } from 'react-hooks-testing-library' -import { Provider as ProviderMock, useRedux } from '../../src/index.js' - -describe('React', () => { - describe('hooks', () => { - describe('useRedux', () => { - let store - - beforeEach(() => { - store = createStore(({ count } = { count: -1 }) => ({ - count: count + 1 - })) - }) - - it('selects the state and binds action creators', () => { - const { result } = renderHook( - () => - useRedux(s => s.count, { - inc: () => ({ type: '' }) - }), - { - wrapper: props => - } - ) - - expect(result.current[0]).toEqual(0) - - act(() => { - result.current[1].inc() - }) - - expect(result.current[0]).toEqual(1) - }) - }) - }) -})