@@ -66,12 +66,53 @@ export interface UseSelectorOptions<Selected = unknown> {
66
66
devModeChecks ?: Partial < DevModeChecks >
67
67
}
68
68
69
+ /**
70
+ * Represents a custom hook that allows you to extract data from the
71
+ * Redux store state, using a selector function. The selector function
72
+ * takes the current state as an argument and returns a part of the state
73
+ * or some derived data. The hook also supports an optional equality
74
+ * function or options object to customize its behavior.
75
+ *
76
+ * @template StateType - The specific type of state this hook operates on.
77
+ *
78
+ * @public
79
+ */
69
80
export interface UseSelector < StateType = unknown > {
81
+ /**
82
+ * A function that takes a selector function as its first argument.
83
+ * The selector function is responsible for selecting a part of
84
+ * the Redux store's state or computing derived data.
85
+ *
86
+ * @param selector - A function that receives the current state and returns a part of the state or some derived data.
87
+ * @param equalityFnOrOptions - An optional equality function or options object for customizing the behavior of the selector.
88
+ * @returns The selected part of the state or derived data.
89
+ *
90
+ * @template TState - The specific type of state this hook operates on.
91
+ * @template Selected - The type of the value that the selector function will return.
92
+ */
70
93
< TState extends StateType = StateType , Selected = unknown > (
71
94
selector : ( state : TState ) => Selected ,
72
95
equalityFnOrOptions ?: EqualityFn < Selected > | UseSelectorOptions < Selected >
73
96
) : Selected
74
97
98
+ /**
99
+ * Creates a "pre-typed" version of {@linkcode useSelector useSelector}
100
+ * where the `state` type is predefined.
101
+ *
102
+ * This allows you to set the `state` type once, eliminating the need to
103
+ * specify it with every {@linkcode useSelector useSelector} call.
104
+ *
105
+ * @returns A pre-typed `useSelector` with the state type already defined.
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * const useAppSelector = useSelector.withTypes<RootState>()
110
+ * ```
111
+ *
112
+ * @template OverrideStateType - The specific type of state this hook operates on.
113
+ *
114
+ * @since 9.1.0
115
+ */
75
116
withTypes : <
76
117
OverrideStateType extends StateType
77
118
> ( ) => UseSelector < OverrideStateType >
0 commit comments