@@ -24,8 +24,6 @@ const useIsomorphicLayoutEffect =
2424 * useful if you provide a selector that memoizes values).
2525 *
2626 * @param {Function } selector the selector function
27- * @param {any[] } deps (optional) dependencies array to control referential stability
28- * of the selector
2927 *
3028 * @returns {any } the selected state
3129 *
@@ -36,11 +34,11 @@ const useIsomorphicLayoutEffect =
3634 * import { RootState } from './store'
3735 *
3836 * export const CounterComponent = () => {
39- * const counter = useSelector(state => state.counter, [] )
37+ * const counter = useSelector(state => state.counter)
4038 * return <div>{counter}</div>
4139 * }
4240 */
43- export function useSelector ( selector , deps ) {
41+ export function useSelector ( selector ) {
4442 invariant ( selector , `You must pass a selector to useSelectors` )
4543
4644 const { store, subscription : contextSub } = useReduxContext ( )
@@ -51,15 +49,13 @@ export function useSelector(selector, deps) {
5149 contextSub
5250 ] )
5351
54- const memoizedSelector = useMemo ( ( ) => selector , deps )
55-
5652 const latestSubscriptionCallbackError = useRef ( )
57- const latestSelector = useRef ( memoizedSelector )
53+ const latestSelector = useRef ( selector )
5854
5955 let selectedState = undefined
6056
6157 try {
62- selectedState = memoizedSelector ( store . getState ( ) )
58+ selectedState = selector ( store . getState ( ) )
6359 } catch ( err ) {
6460 let errorMessage = `An error occured while selecting the store state: ${
6561 err . message
@@ -77,7 +73,7 @@ export function useSelector(selector, deps) {
7773 const latestSelectedState = useRef ( selectedState )
7874
7975 useIsomorphicLayoutEffect ( ( ) => {
80- latestSelector . current = memoizedSelector
76+ latestSelector . current = selector
8177 latestSelectedState . current = selectedState
8278 latestSubscriptionCallbackError . current = undefined
8379 } )
0 commit comments