Skip to content

Commit

Permalink
wrap type in
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas authored and markerikson committed Nov 4, 2022
1 parent ad40b97 commit 3b06061
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/hooks/useSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useContext, useDebugValue } from 'react'

import { useReduxContext as useDefaultReduxContext } from './useReduxContext'
import { ReactReduxContext } from '../components/Context'
import type { EqualityFn } from '../types'
import type { EqualityFn, NoInfer } from '../types'
import type { uSESWS } from '../utils/useSyncExternalStore'
import { notInitialized } from '../utils/useSyncExternalStore'

Expand Down Expand Up @@ -32,7 +32,7 @@ export function createSelectorHook(

return function useSelector<TState, Selected extends unknown>(
selector: (state: TState) => Selected,
equalityFn: EqualityFn<Selected> = refEquality
equalityFn: EqualityFn<NoInfer<Selected>> = refEquality
): Selected {
if (process.env.NODE_ENV !== 'production') {
if (!selector) {
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,5 @@ export interface TypedUseSelectorHook<TState> {
equalityFn?: EqualityFn<TSelected>
): TSelected
}

export type NoInfer<T> = [T][T extends any ? 0 : never]

0 comments on commit 3b06061

Please sign in to comment.