react-saga-redux 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +63 -0
  3. package/dist/index.d.mts +569 -0
  4. package/dist/index.d.ts +569 -0
  5. package/dist/index.js +1188 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/index.mjs +1138 -0
  8. package/dist/index.mjs.map +1 -0
  9. package/package.json +100 -0
  10. package/src/components/Context.ts +50 -0
  11. package/src/components/Props.ts +111 -0
  12. package/src/components/Provider.tsx +105 -0
  13. package/src/components/connect.tsx +813 -0
  14. package/src/connect/invalidArgFactory.ts +14 -0
  15. package/src/connect/mapDispatchToProps.ts +25 -0
  16. package/src/connect/mapProps.ts +43 -0
  17. package/src/connect/mapStateToProps.ts +14 -0
  18. package/src/connect/mergeProps.ts +78 -0
  19. package/src/connect/selectorFactory.ts +242 -0
  20. package/src/connect/verifySubselectors.ts +26 -0
  21. package/src/connect/wrapMapToProps.ts +110 -0
  22. package/src/exports.ts +54 -0
  23. package/src/hooks/useDispatch.ts +104 -0
  24. package/src/hooks/useReduxContext.ts +42 -0
  25. package/src/hooks/useSelector.ts +286 -0
  26. package/src/hooks/useStore.ts +123 -0
  27. package/src/index-rsc.ts +34 -0
  28. package/src/index.ts +1 -0
  29. package/src/types.ts +180 -0
  30. package/src/utils/Subscription.ts +183 -0
  31. package/src/utils/batch.ts +4 -0
  32. package/src/utils/bindActionCreators.ts +16 -0
  33. package/src/utils/constants.ts +23 -0
  34. package/src/utils/hoistStatics.ts +139 -0
  35. package/src/utils/isPlainObject.ts +17 -0
  36. package/src/utils/react-is.ts +97 -0
  37. package/src/utils/react.ts +3 -0
  38. package/src/utils/shallowEqual.ts +36 -0
  39. package/src/utils/useIsomorphicLayoutEffect.ts +40 -0
  40. package/src/utils/useSyncExternalStore.ts +9 -0
  41. package/src/utils/verifyPlainObject.ts +14 -0
  42. package/src/utils/warning.ts +21 -0
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015-present Dan Abramov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # React Redux
2
+
3
+ Official React bindings for [Redux](https://github.com/reduxjs/redux).
4
+ Performant and flexible.
5
+
6
+ ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/reduxjs/react-redux/test.yml?style=flat-square) [![npm version](https://img.shields.io/npm/v/react-redux.svg?style=flat-square)](https://www.npmjs.com/package/react-redux)
7
+ [![npm downloads](https://img.shields.io/npm/dm/react-redux.svg?style=flat-square)](https://www.npmjs.com/package/react-redux)
8
+ [![#redux channel on Discord](https://img.shields.io/badge/discord-redux@reactiflux-61DAFB.svg?style=flat-square)](http://www.reactiflux.com)
9
+
10
+ ## Installation
11
+
12
+ ### Create a React Redux App
13
+
14
+ The recommended way to start new apps with React and Redux is by using [our official Redux+TS template for Vite](https://github.com/reduxjs/redux-templates), or by creating a new Next.js project using [Next's `with-redux` template](https://github.com/vercel/next.js/tree/canary/examples/with-redux).
15
+
16
+ Both of these already have Redux Toolkit and React-Redux configured appropriately for that build tool, and come with a small example app that demonstrates how to use several of Redux Toolkit's features.
17
+
18
+ ```bash
19
+ # Vite with our Redux+TS template
20
+ # (using the `degit` tool to clone and extract the template)
21
+ npx degit reduxjs/redux-templates/packages/vite-template-redux my-app
22
+
23
+ # Next.js using the `with-redux` template
24
+ npx create-next-app --example with-redux my-app
25
+ ```
26
+
27
+ ### An Existing React App
28
+
29
+ React Redux 8.0 requires **React 16.8.3 or later** (or React Native 0.59 or later).
30
+
31
+ To use React Redux with your React app, install it as a dependency:
32
+
33
+ ```bash
34
+ # If you use npm:
35
+ npm install react-redux
36
+
37
+ # Or if you use Yarn:
38
+ yarn add react-redux
39
+ ```
40
+
41
+ You'll also need to [install Redux](https://redux.js.org/introduction/installation) and [set up a Redux store](https://redux.js.org/recipes/configuring-your-store/) in your app.
42
+
43
+ This assumes that you’re using [npm](http://npmjs.com/) package manager
44
+ with a module bundler like [Webpack](https://webpack.js.org/) or
45
+ [Browserify](http://browserify.org/) to consume [CommonJS
46
+ modules](https://webpack.js.org/api/module-methods/#commonjs).
47
+
48
+ If you don’t yet use [npm](http://npmjs.com/) or a modern module bundler, and would rather prefer a single-file [UMD](https://github.com/umdjs/umd) build that makes `ReactRedux` available as a global object, you can grab a pre-built version from [cdnjs](https://cdnjs.com/libraries/react-redux). We _don’t_ recommend this approach for any serious application, as most of the libraries complementary to Redux are only available on [npm](http://npmjs.com/).
49
+
50
+ ## Documentation
51
+
52
+ The React Redux docs are published at **https://react-redux.js.org** .
53
+
54
+ ## How Does It Work?
55
+
56
+ The post [The History and Implementation of React-Redux](https://blog.isquaredsoftware.com/2018/11/react-redux-history-implementation/)
57
+ explains what it does, how it works, and how the API and implementation have evolved over time.
58
+
59
+ There's also a [Deep Dive into React-Redux](https://blog.isquaredsoftware.com/2019/06/presentation-react-redux-deep-dive/) talk that covers some of the same material at a higher level.
60
+
61
+ ## License
62
+
63
+ [MIT](LICENSE.md)
@@ -0,0 +1,569 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+ import { MemoExoticComponent, ForwardRefExoticComponent, Context, ReactNode, ComponentType, ComponentClass, ClassAttributes, FunctionComponent, JSX } from 'react';
4
+ import { Action, UnknownAction, Store, Dispatch } from 'redux';
5
+
6
+ /**
7
+ * Copyright 2015, Yahoo! Inc.
8
+ * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
9
+ */
10
+
11
+ declare const REACT_STATICS: {
12
+ readonly childContextTypes: true;
13
+ readonly contextType: true;
14
+ readonly contextTypes: true;
15
+ readonly defaultProps: true;
16
+ readonly displayName: true;
17
+ readonly getDefaultProps: true;
18
+ readonly getDerivedStateFromError: true;
19
+ readonly getDerivedStateFromProps: true;
20
+ readonly mixins: true;
21
+ readonly propTypes: true;
22
+ readonly type: true;
23
+ };
24
+ declare const KNOWN_STATICS: {
25
+ readonly name: true;
26
+ readonly length: true;
27
+ readonly prototype: true;
28
+ readonly caller: true;
29
+ readonly callee: true;
30
+ readonly arguments: true;
31
+ readonly arity: true;
32
+ };
33
+ declare const FORWARD_REF_STATICS: {
34
+ readonly $$typeof: true;
35
+ readonly render: true;
36
+ readonly defaultProps: true;
37
+ readonly displayName: true;
38
+ readonly propTypes: true;
39
+ };
40
+ declare const MEMO_STATICS: {
41
+ readonly $$typeof: true;
42
+ readonly compare: true;
43
+ readonly defaultProps: true;
44
+ readonly displayName: true;
45
+ readonly propTypes: true;
46
+ readonly type: true;
47
+ };
48
+ type NonReactStatics<Source, C extends {
49
+ [key: string]: true;
50
+ } = {}> = {
51
+ [key in Exclude<keyof Source, Source extends MemoExoticComponent<any> ? keyof typeof MEMO_STATICS | keyof C : Source extends ForwardRefExoticComponent<any> ? keyof typeof FORWARD_REF_STATICS | keyof C : keyof typeof REACT_STATICS | keyof typeof KNOWN_STATICS | keyof C>]: Source[key];
52
+ };
53
+
54
+ type VoidFunc = () => void;
55
+ type Listener = {
56
+ callback: VoidFunc;
57
+ next: Listener | null;
58
+ prev: Listener | null;
59
+ };
60
+ declare function createListenerCollection(): {
61
+ clear(): void;
62
+ notify(): void;
63
+ get(): Listener[];
64
+ subscribe(callback: () => void): () => void;
65
+ };
66
+ type ListenerCollection = ReturnType<typeof createListenerCollection>;
67
+ interface Subscription {
68
+ addNestedSub: (listener: VoidFunc) => VoidFunc;
69
+ notifyNestedSubs: VoidFunc;
70
+ handleChangeWrapper: VoidFunc;
71
+ isSubscribed: () => boolean;
72
+ onStateChange?: VoidFunc | null;
73
+ trySubscribe: VoidFunc;
74
+ tryUnsubscribe: VoidFunc;
75
+ getListeners: () => ListenerCollection;
76
+ }
77
+
78
+ interface ProviderProps<A extends Action<string> = UnknownAction, S = unknown> {
79
+ /**
80
+ * The single Redux store in your application.
81
+ */
82
+ store: Store<S, A>;
83
+ /**
84
+ * An optional server state snapshot. Will be used during initial hydration render if available, to ensure that the UI output is consistent with the HTML generated on the server.
85
+ */
86
+ serverState?: S;
87
+ /**
88
+ * Optional context to be used internally in react-redux. Use React.createContext() to create a context to be used.
89
+ * If this is used, you'll need to customize `connect` by supplying the same context provided to the Provider.
90
+ * Set the initial value to null, and the hooks will error
91
+ * if this is not overwritten by Provider.
92
+ */
93
+ context?: Context<ReactReduxContextValue<S, A> | null>;
94
+ /**
95
+ * Determines the frequency of stability checks for all selectors.
96
+ * This setting overrides the global configuration for
97
+ * the `useSelector` stability check, allowing you to specify how often
98
+ * these checks should occur in development mode.
99
+ *
100
+ * @since 8.1.0
101
+ */
102
+ stabilityCheck?: DevModeCheckFrequency;
103
+ /**
104
+ * Determines the frequency of identity function checks for all selectors.
105
+ * This setting overrides the global configuration for
106
+ * the `useSelector` identity function check, allowing you to specify how often
107
+ * these checks should occur in development mode.
108
+ *
109
+ * **Note**: Previously referred to as `noopCheck`.
110
+ *
111
+ * @since 9.0.0
112
+ */
113
+ identityFunctionCheck?: DevModeCheckFrequency;
114
+ children: ReactNode;
115
+ }
116
+ declare function Provider<A extends Action<string> = UnknownAction, S = unknown>(providerProps: ProviderProps<A, S>): react_jsx_runtime.JSX.Element;
117
+
118
+ interface ReactReduxContextValue<SS = any, A extends Action<string> = UnknownAction> extends Pick<ProviderProps, 'stabilityCheck' | 'identityFunctionCheck'> {
119
+ store: Store<SS, A>;
120
+ subscription: Subscription;
121
+ getServerState?: () => SS;
122
+ }
123
+ declare const ReactReduxContext: Context<ReactReduxContextValue<any, UnknownAction>>;
124
+ type ReactReduxContextInstance = typeof ReactReduxContext;
125
+
126
+ /**
127
+ * The frequency of development mode checks.
128
+ *
129
+ * @since 8.1.0
130
+ * @internal
131
+ */
132
+ type DevModeCheckFrequency = 'never' | 'once' | 'always';
133
+ /**
134
+ * Represents the configuration for development mode checks.
135
+ *
136
+ * @since 9.0.0
137
+ * @internal
138
+ */
139
+ interface DevModeChecks {
140
+ /**
141
+ * Overrides the global stability check for the selector.
142
+ * - `once` - Run only the first time the selector is called.
143
+ * - `always` - Run every time the selector is called.
144
+ * - `never` - Never run the stability check.
145
+ *
146
+ * @default 'once'
147
+ *
148
+ * @since 8.1.0
149
+ */
150
+ stabilityCheck: DevModeCheckFrequency;
151
+ /**
152
+ * Overrides the global identity function check for the selector.
153
+ * - `once` - Run only the first time the selector is called.
154
+ * - `always` - Run every time the selector is called.
155
+ * - `never` - Never run the identity function check.
156
+ *
157
+ * **Note**: Previously referred to as `noopCheck`.
158
+ *
159
+ * @default 'once'
160
+ *
161
+ * @since 9.0.0
162
+ */
163
+ identityFunctionCheck: DevModeCheckFrequency;
164
+ }
165
+ interface UseSelectorOptions<Selected = unknown> {
166
+ equalityFn?: EqualityFn<Selected>;
167
+ /**
168
+ * `useSelector` performs additional checks in development mode to help
169
+ * identify and warn about potential issues in selector behavior. This
170
+ * option allows you to customize the behavior of these checks per selector.
171
+ *
172
+ * @since 9.0.0
173
+ */
174
+ devModeChecks?: Partial<DevModeChecks>;
175
+ }
176
+ /**
177
+ * Represents a custom hook that allows you to extract data from the
178
+ * Redux store state, using a selector function. The selector function
179
+ * takes the current state as an argument and returns a part of the state
180
+ * or some derived data. The hook also supports an optional equality
181
+ * function or options object to customize its behavior.
182
+ *
183
+ * @template StateType - The specific type of state this hook operates on.
184
+ *
185
+ * @public
186
+ */
187
+ interface UseSelector<StateType = unknown> {
188
+ /**
189
+ * A function that takes a selector function as its first argument.
190
+ * The selector function is responsible for selecting a part of
191
+ * the Redux store's state or computing derived data.
192
+ *
193
+ * @param selector - A function that receives the current state and returns a part of the state or some derived data.
194
+ * @param equalityFnOrOptions - An optional equality function or options object for customizing the behavior of the selector.
195
+ * @returns The selected part of the state or derived data.
196
+ *
197
+ * @template TState - The specific type of state this hook operates on.
198
+ * @template Selected - The type of the value that the selector function will return.
199
+ */
200
+ <TState extends StateType = StateType, Selected = unknown>(selector: (state: TState) => Selected, equalityFnOrOptions?: EqualityFn<Selected> | UseSelectorOptions<Selected>): Selected;
201
+ /**
202
+ * Creates a "pre-typed" version of {@linkcode useSelector useSelector}
203
+ * where the `state` type is predefined.
204
+ *
205
+ * This allows you to set the `state` type once, eliminating the need to
206
+ * specify it with every {@linkcode useSelector useSelector} call.
207
+ *
208
+ * @returns A pre-typed `useSelector` with the state type already defined.
209
+ *
210
+ * @example
211
+ * ```ts
212
+ * export const useAppSelector = useSelector.withTypes<RootState>()
213
+ * ```
214
+ *
215
+ * @template OverrideStateType - The specific type of state this hook operates on.
216
+ *
217
+ * @since 9.1.0
218
+ */
219
+ withTypes: <OverrideStateType extends StateType>() => UseSelector<OverrideStateType>;
220
+ }
221
+ /**
222
+ * Hook factory, which creates a `useSelector` hook bound to a given context.
223
+ *
224
+ * @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
225
+ * @returns {Function} A `useSelector` hook bound to the specified context.
226
+ */
227
+ declare function createSelectorHook(context?: React.Context<ReactReduxContextValue<any, any> | null>): UseSelector;
228
+ /**
229
+ * A hook to access the redux store's state. This hook takes a selector function
230
+ * as an argument. The selector is called with the store state.
231
+ *
232
+ * This hook takes an optional equality comparison function as the second parameter
233
+ * that allows you to customize the way the selected state is compared to determine
234
+ * whether the component needs to be re-rendered.
235
+ *
236
+ * @param {Function} selector the selector function
237
+ * @param {Function=} equalityFn the function that will be used to determine equality
238
+ *
239
+ * @returns {any} the selected state
240
+ *
241
+ * @example
242
+ *
243
+ * import React from 'react'
244
+ * import { useSelector } from 'react-redux'
245
+ *
246
+ * export const CounterComponent = () => {
247
+ * const counter = useSelector(state => state.counter)
248
+ * return <div>{counter}</div>
249
+ * }
250
+ */
251
+ declare const useSelector: UseSelector<unknown>;
252
+
253
+ type FixTypeLater = any;
254
+ type EqualityFn<T> = (a: T, b: T) => boolean;
255
+ type ExtendedEqualityFn<T, P> = (a: T, b: T, c: P, d: P) => boolean;
256
+ type AnyIfEmpty<T extends object> = keyof T extends never ? any : T;
257
+ type DistributiveOmit<T, K extends keyof T> = T extends unknown ? Omit<T, K> : never;
258
+ interface DispatchProp<A extends Action<string> = UnknownAction> {
259
+ dispatch: Dispatch<A>;
260
+ }
261
+ /**
262
+ * A property P will be present if:
263
+ * - it is present in DecorationTargetProps
264
+ *
265
+ * Its value will be dependent on the following conditions
266
+ * - if property P is present in InjectedProps and its definition extends the definition
267
+ * in DecorationTargetProps, then its definition will be that of DecorationTargetProps[P]
268
+ * - if property P is not present in InjectedProps then its definition will be that of
269
+ * DecorationTargetProps[P]
270
+ * - if property P is present in InjectedProps but does not extend the
271
+ * DecorationTargetProps[P] definition, its definition will be that of InjectedProps[P]
272
+ */
273
+ type Matching<InjectedProps, DecorationTargetProps> = {
274
+ [P in keyof DecorationTargetProps]: P extends keyof InjectedProps ? InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : InjectedProps[P] : DecorationTargetProps[P];
275
+ };
276
+ /**
277
+ * a property P will be present if :
278
+ * - it is present in both DecorationTargetProps and InjectedProps
279
+ * - InjectedProps[P] can satisfy DecorationTargetProps[P]
280
+ * ie: decorated component can accept more types than decorator is injecting
281
+ *
282
+ * For decoration, inject props or ownProps are all optionally
283
+ * required by the decorated (right hand side) component.
284
+ * But any property required by the decorated component must be satisfied by the injected property.
285
+ */
286
+ type Shared<InjectedProps, DecorationTargetProps> = {
287
+ [P in Extract<keyof InjectedProps, keyof DecorationTargetProps>]?: InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : never;
288
+ };
289
+ type GetProps<C> = C extends ComponentType<infer P> ? C extends ComponentClass<P> ? ClassAttributes<InstanceType<C>> & P : P : never;
290
+ type GetLibraryManagedProps<C> = JSX.LibraryManagedAttributes<C, GetProps<C>>;
291
+ type ConnectedComponent<C extends ComponentType<any>, P> = FunctionComponent<P> & NonReactStatics<C> & {
292
+ WrappedComponent: C;
293
+ };
294
+ type ConnectPropsMaybeWithoutContext<TActualOwnProps> = TActualOwnProps extends {
295
+ context: any;
296
+ } ? Omit<ConnectProps, 'context'> : ConnectProps;
297
+ type Identity<T> = T;
298
+ type Mapped<T> = Identity<{
299
+ [k in keyof T]: T[k];
300
+ }>;
301
+ type InferableComponentEnhancerWithProps<TInjectedProps, TNeedsProps> = <C extends ComponentType<Matching<TInjectedProps, GetProps<C>>>>(component: C) => ConnectedComponent<C, Mapped<DistributiveOmit<GetLibraryManagedProps<C>, keyof Shared<TInjectedProps, GetLibraryManagedProps<C>>> & TNeedsProps & ConnectPropsMaybeWithoutContext<TNeedsProps & GetProps<C>>>>;
302
+ type InferableComponentEnhancer<TInjectedProps> = InferableComponentEnhancerWithProps<TInjectedProps, {}>;
303
+ type InferThunkActionCreatorType<TActionCreator extends (...args: any[]) => any> = TActionCreator extends (...args: infer TParams) => (...args: any[]) => infer TReturn ? (...args: TParams) => TReturn : TActionCreator;
304
+ type HandleThunkActionCreator<TActionCreator> = TActionCreator extends (...args: any[]) => any ? InferThunkActionCreatorType<TActionCreator> : TActionCreator;
305
+ type ResolveThunks<TDispatchProps> = TDispatchProps extends {
306
+ [key: string]: any;
307
+ } ? {
308
+ [C in keyof TDispatchProps]: HandleThunkActionCreator<TDispatchProps[C]>;
309
+ } : TDispatchProps;
310
+ /**
311
+ * This interface allows you to easily create a hook that is properly typed for your
312
+ * store's root state.
313
+ *
314
+ * @example
315
+ *
316
+ * interface RootState {
317
+ * property: string;
318
+ * }
319
+ *
320
+ * const useTypedSelector: TypedUseSelectorHook<RootState> = useSelector;
321
+ */
322
+ interface TypedUseSelectorHook<TState> {
323
+ <TSelected>(selector: (state: TState) => TSelected, equalityFn?: EqualityFn<NoInfer<TSelected>>): TSelected;
324
+ <Selected = unknown>(selector: (state: TState) => Selected, options?: UseSelectorOptions<Selected>): Selected;
325
+ }
326
+ type NoInfer<T> = [T][T extends any ? 0 : never];
327
+
328
+ type SelectorFactory<S, TProps, TOwnProps, TFactoryOptions> = (dispatch: Dispatch<Action<string>>, factoryOptions: TFactoryOptions) => Selector<S, TProps, TOwnProps>;
329
+ type Selector<S, TProps, TOwnProps = null> = TOwnProps extends null | undefined ? (state: S) => TProps : (state: S, ownProps: TOwnProps) => TProps;
330
+ type MapStateToProps<TStateProps, TOwnProps, State> = (state: State, ownProps: TOwnProps) => TStateProps;
331
+ type MapStateToPropsFactory<TStateProps, TOwnProps, State> = (initialState: State, ownProps: TOwnProps) => MapStateToProps<TStateProps, TOwnProps, State>;
332
+ type MapStateToPropsParam<TStateProps, TOwnProps, State> = MapStateToPropsFactory<TStateProps, TOwnProps, State> | MapStateToProps<TStateProps, TOwnProps, State> | null | undefined;
333
+ type MapDispatchToPropsFunction<TDispatchProps, TOwnProps> = (dispatch: Dispatch<Action<string>>, ownProps: TOwnProps) => TDispatchProps;
334
+ type MapDispatchToProps<TDispatchProps, TOwnProps> = MapDispatchToPropsFunction<TDispatchProps, TOwnProps> | TDispatchProps;
335
+ type MapDispatchToPropsFactory<TDispatchProps, TOwnProps> = (dispatch: Dispatch<Action<string>>, ownProps: TOwnProps) => MapDispatchToPropsFunction<TDispatchProps, TOwnProps>;
336
+ type MapDispatchToPropsParam<TDispatchProps, TOwnProps> = MapDispatchToPropsFactory<TDispatchProps, TOwnProps> | MapDispatchToProps<TDispatchProps, TOwnProps>;
337
+ type MapDispatchToPropsNonObject<TDispatchProps, TOwnProps> = MapDispatchToPropsFactory<TDispatchProps, TOwnProps> | MapDispatchToPropsFunction<TDispatchProps, TOwnProps>;
338
+ type MergeProps<TStateProps, TDispatchProps, TOwnProps, TMergedProps> = (stateProps: TStateProps, dispatchProps: TDispatchProps, ownProps: TOwnProps) => TMergedProps;
339
+
340
+ interface ConnectProps {
341
+ /** A custom Context instance that the component can use to access the store from an alternate Provider using that same Context instance */
342
+ context?: ReactReduxContextInstance;
343
+ /** A Redux store instance to be used for subscriptions instead of the store from a Provider */
344
+ store?: Store;
345
+ }
346
+ /**
347
+ * Infers the type of props that a connector will inject into a component.
348
+ */
349
+ type ConnectedProps<TConnector> = TConnector extends InferableComponentEnhancerWithProps<infer TInjectedProps, any> ? unknown extends TInjectedProps ? TConnector extends InferableComponentEnhancer<infer TInjectedProps> ? TInjectedProps : never : TInjectedProps : never;
350
+ interface ConnectOptions<State = unknown, TStateProps = {}, TOwnProps = {}, TMergedProps = {}> {
351
+ forwardRef?: boolean;
352
+ context?: typeof ReactReduxContext;
353
+ areStatesEqual?: (nextState: State, prevState: State, nextOwnProps: TOwnProps, prevOwnProps: TOwnProps) => boolean;
354
+ areOwnPropsEqual?: (nextOwnProps: TOwnProps, prevOwnProps: TOwnProps) => boolean;
355
+ areStatePropsEqual?: (nextStateProps: TStateProps, prevStateProps: TStateProps) => boolean;
356
+ areMergedPropsEqual?: (nextMergedProps: TMergedProps, prevMergedProps: TMergedProps) => boolean;
357
+ }
358
+ /**
359
+ * Connects a React component to a Redux store.
360
+ *
361
+ * - Without arguments, just wraps the component, without changing the behavior / props
362
+ *
363
+ * - If 2 params are passed (3rd param, mergeProps, is skipped), default behavior
364
+ * is to override ownProps (as stated in the docs), so what remains is everything that's
365
+ * not a state or dispatch prop
366
+ *
367
+ * - When 3rd param is passed, we don't know if ownProps propagate and whether they
368
+ * should be valid component props, because it depends on mergeProps implementation.
369
+ * As such, it is the user's responsibility to extend ownProps interface from state or
370
+ * dispatch props or both when applicable
371
+ *
372
+ * @param mapStateToProps
373
+ * @param mapDispatchToProps
374
+ * @param mergeProps
375
+ * @param options
376
+ */
377
+ interface Connect<DefaultState = unknown> {
378
+ (): InferableComponentEnhancer<DispatchProp>;
379
+ /** mapState only */
380
+ <TStateProps = {}, no_dispatch = {}, TOwnProps = {}, State = DefaultState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>): InferableComponentEnhancerWithProps<TStateProps & DispatchProp, TOwnProps>;
381
+ /** mapDispatch only (as a function) */
382
+ <no_state = {}, TDispatchProps = {}, TOwnProps = {}>(mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>): InferableComponentEnhancerWithProps<TDispatchProps, TOwnProps>;
383
+ /** mapDispatch only (as an object) */
384
+ <no_state = {}, TDispatchProps = {}, TOwnProps = {}>(mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>): InferableComponentEnhancerWithProps<ResolveThunks<TDispatchProps>, TOwnProps>;
385
+ /** mapState and mapDispatch (as a function)*/
386
+ <TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, State = DefaultState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>): InferableComponentEnhancerWithProps<TStateProps & TDispatchProps, TOwnProps>;
387
+ /** mapState and mapDispatch (nullish) */
388
+ <TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, State = DefaultState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: null | undefined): InferableComponentEnhancerWithProps<TStateProps, TOwnProps>;
389
+ /** mapState and mapDispatch (as an object) */
390
+ <TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, State = DefaultState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>): InferableComponentEnhancerWithProps<TStateProps & ResolveThunks<TDispatchProps>, TOwnProps>;
391
+ /** mergeProps only */
392
+ <no_state = {}, no_dispatch = {}, TOwnProps = {}, TMergedProps = {}>(mapStateToProps: null | undefined, mapDispatchToProps: null | undefined, mergeProps: MergeProps<undefined, DispatchProp, TOwnProps, TMergedProps>): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>;
393
+ /** mapState and mergeProps */
394
+ <TStateProps = {}, no_dispatch = {}, TOwnProps = {}, TMergedProps = {}, State = DefaultState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: null | undefined, mergeProps: MergeProps<TStateProps, DispatchProp, TOwnProps, TMergedProps>): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>;
395
+ /** mapDispatch (as a object) and mergeProps */
396
+ <no_state = {}, TDispatchProps = {}, TOwnProps = {}, TMergedProps = {}>(mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>, mergeProps: MergeProps<undefined, TDispatchProps, TOwnProps, TMergedProps>): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>;
397
+ /** mapState and options */
398
+ <TStateProps = {}, no_dispatch = {}, TOwnProps = {}, State = DefaultState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: null | undefined, mergeProps: null | undefined, options: ConnectOptions<State, TStateProps, TOwnProps>): InferableComponentEnhancerWithProps<DispatchProp & TStateProps, TOwnProps>;
399
+ /** mapDispatch (as a function) and options */
400
+ <TStateProps = {}, TDispatchProps = {}, TOwnProps = {}>(mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>, mergeProps: null | undefined, options: ConnectOptions<{}, TStateProps, TOwnProps>): InferableComponentEnhancerWithProps<TDispatchProps, TOwnProps>;
401
+ /** mapDispatch (as an object) and options*/
402
+ <TStateProps = {}, TDispatchProps = {}, TOwnProps = {}>(mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>, mergeProps: null | undefined, options: ConnectOptions<{}, TStateProps, TOwnProps>): InferableComponentEnhancerWithProps<ResolveThunks<TDispatchProps>, TOwnProps>;
403
+ /** mapState, mapDispatch (as a function), and options */
404
+ <TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, State = DefaultState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>, mergeProps: null | undefined, options: ConnectOptions<State, TStateProps, TOwnProps>): InferableComponentEnhancerWithProps<TStateProps & TDispatchProps, TOwnProps>;
405
+ /** mapState, mapDispatch (as an object), and options */
406
+ <TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, State = DefaultState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>, mergeProps: null | undefined, options: ConnectOptions<State, TStateProps, TOwnProps>): InferableComponentEnhancerWithProps<TStateProps & ResolveThunks<TDispatchProps>, TOwnProps>;
407
+ /** mapState, mapDispatch, mergeProps, and options */
408
+ <TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, TMergedProps = {}, State = DefaultState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>, mergeProps: MergeProps<TStateProps, TDispatchProps, TOwnProps, TMergedProps>, options?: ConnectOptions<State, TStateProps, TOwnProps, TMergedProps>): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>;
409
+ }
410
+ declare const _default: Connect;
411
+
412
+ declare function shallowEqual(objA: any, objB: any): boolean;
413
+
414
+ declare const middleware: (...args: any[]) => (_req: any, _res: any, next: any) => void;
415
+
416
+ declare function defaultNoopBatch(callback: () => void): void;
417
+
418
+ /**
419
+ * Represents a custom hook that provides a dispatch function
420
+ * from the Redux store.
421
+ *
422
+ * @template DispatchType - The specific type of the dispatch function.
423
+ *
424
+ * @since 9.1.0
425
+ * @public
426
+ */
427
+ interface UseDispatch<DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> {
428
+ /**
429
+ * Returns the dispatch function from the Redux store.
430
+ *
431
+ * @returns The dispatch function from the Redux store.
432
+ *
433
+ * @template AppDispatch - The specific type of the dispatch function.
434
+ */
435
+ <AppDispatch extends DispatchType = DispatchType>(): AppDispatch;
436
+ /**
437
+ * Creates a "pre-typed" version of {@linkcode useDispatch useDispatch}
438
+ * where the type of the `dispatch` function is predefined.
439
+ *
440
+ * This allows you to set the `dispatch` type once, eliminating the need to
441
+ * specify it with every {@linkcode useDispatch useDispatch} call.
442
+ *
443
+ * @returns A pre-typed `useDispatch` with the dispatch type already defined.
444
+ *
445
+ * @example
446
+ * ```ts
447
+ * export const useAppDispatch = useDispatch.withTypes<AppDispatch>()
448
+ * ```
449
+ *
450
+ * @template OverrideDispatchType - The specific type of the dispatch function.
451
+ *
452
+ * @since 9.1.0
453
+ */
454
+ withTypes: <OverrideDispatchType extends DispatchType>() => UseDispatch<OverrideDispatchType>;
455
+ }
456
+ /**
457
+ * Hook factory, which creates a `useDispatch` hook bound to a given context.
458
+ *
459
+ * @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
460
+ * @returns {Function} A `useDispatch` hook bound to the specified context.
461
+ */
462
+ declare function createDispatchHook<StateType = unknown, ActionType extends Action = UnknownAction>(context?: Context<ReactReduxContextValue<StateType, ActionType> | null>): UseDispatch<Dispatch<ActionType>>;
463
+ /**
464
+ * A hook to access the redux `dispatch` function.
465
+ *
466
+ * @returns {any|function} redux store's `dispatch` function
467
+ *
468
+ * @example
469
+ *
470
+ * import React, { useCallback } from 'react'
471
+ * import { useDispatch } from 'react-redux'
472
+ *
473
+ * export const CounterComponent = ({ value }) => {
474
+ * const dispatch = useDispatch()
475
+ * const increaseCounter = useCallback(() => dispatch({ type: 'increase-counter' }), [])
476
+ * return (
477
+ * <div>
478
+ * <span>{value}</span>
479
+ * <button onClick={increaseCounter}>Increase counter</button>
480
+ * </div>
481
+ * )
482
+ * }
483
+ */
484
+ declare const useDispatch: UseDispatch<Dispatch<UnknownAction>>;
485
+
486
+ /**
487
+ * Represents a type that extracts the action type from a given Redux store.
488
+ *
489
+ * @template StoreType - The specific type of the Redux store.
490
+ *
491
+ * @since 9.1.0
492
+ * @internal
493
+ */
494
+ type ExtractStoreActionType<StoreType extends Store> = StoreType extends Store<any, infer ActionType> ? ActionType : never;
495
+ /**
496
+ * Represents a custom hook that provides access to the Redux store.
497
+ *
498
+ * @template StoreType - The specific type of the Redux store that gets returned.
499
+ *
500
+ * @since 9.1.0
501
+ * @public
502
+ */
503
+ interface UseStore<StoreType extends Store> {
504
+ /**
505
+ * Returns the Redux store instance.
506
+ *
507
+ * @returns The Redux store instance.
508
+ */
509
+ (): StoreType;
510
+ /**
511
+ * Returns the Redux store instance with specific state and action types.
512
+ *
513
+ * @returns The Redux store with the specified state and action types.
514
+ *
515
+ * @template StateType - The specific type of the state used in the store.
516
+ * @template ActionType - The specific type of the actions used in the store.
517
+ */
518
+ <StateType extends ReturnType<StoreType['getState']> = ReturnType<StoreType['getState']>, ActionType extends Action = ExtractStoreActionType<Store>>(): Store<StateType, ActionType>;
519
+ /**
520
+ * Creates a "pre-typed" version of {@linkcode useStore useStore}
521
+ * where the type of the Redux `store` is predefined.
522
+ *
523
+ * This allows you to set the `store` type once, eliminating the need to
524
+ * specify it with every {@linkcode useStore useStore} call.
525
+ *
526
+ * @returns A pre-typed `useStore` with the store type already defined.
527
+ *
528
+ * @example
529
+ * ```ts
530
+ * export const useAppStore = useStore.withTypes<AppStore>()
531
+ * ```
532
+ *
533
+ * @template OverrideStoreType - The specific type of the Redux store that gets returned.
534
+ *
535
+ * @since 9.1.0
536
+ */
537
+ withTypes: <OverrideStoreType extends StoreType>() => UseStore<OverrideStoreType>;
538
+ }
539
+ /**
540
+ * Hook factory, which creates a `useStore` hook bound to a given context.
541
+ *
542
+ * @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
543
+ * @returns {Function} A `useStore` hook bound to the specified context.
544
+ */
545
+ declare function createStoreHook<StateType = unknown, ActionType extends Action = Action>(context?: Context<ReactReduxContextValue<StateType, ActionType> | null>): UseStore<Store<StateType, ActionType>>;
546
+ /**
547
+ * A hook to access the redux store.
548
+ *
549
+ * @returns {any} the redux store
550
+ *
551
+ * @example
552
+ *
553
+ * import React from 'react'
554
+ * import { useStore } from 'react-redux'
555
+ *
556
+ * export const ExampleComponent = () => {
557
+ * const store = useStore()
558
+ * return <div>{store.getState()}</div>
559
+ * }
560
+ */
561
+ declare const useStore: UseStore<Store<unknown, Action, unknown>>;
562
+
563
+ /**
564
+ * @deprecated As of React 18, batching is enabled by default for ReactDOM and React Native.
565
+ * This is now a no-op that immediately runs the callback.
566
+ */
567
+ declare const batch: typeof defaultNoopBatch;
568
+
569
+ export { type AnyIfEmpty, type Connect, type ConnectProps, type ConnectPropsMaybeWithoutContext, type ConnectedComponent, type ConnectedProps, type DispatchProp, type DistributiveOmit, type EqualityFn, type ExtendedEqualityFn, type FixTypeLater, type GetLibraryManagedProps, type GetProps, type HandleThunkActionCreator, type InferThunkActionCreatorType, type InferableComponentEnhancer, type InferableComponentEnhancerWithProps, type MapDispatchToProps, type MapDispatchToPropsFactory, type MapDispatchToPropsFunction, type MapDispatchToPropsNonObject, type MapDispatchToPropsParam, type MapStateToProps, type MapStateToPropsFactory, type MapStateToPropsParam, type Mapped, type Matching, type MergeProps, type NoInfer, Provider, type ProviderProps, ReactReduxContext, type ReactReduxContextValue, type ResolveThunks, type Selector, type SelectorFactory, type Shared, type Subscription, type TypedUseSelectorHook, type UseDispatch, type UseSelector, type UseStore, batch, _default as connect, createDispatchHook, createSelectorHook, createStoreHook, middleware, shallowEqual, useDispatch, useSelector, useStore };