UNPKG

29.3 kBTypeScriptView Raw
1import * as React$1 from 'react';
2import { Context, ReactNode, ComponentType, ComponentClass, ClassAttributes, JSX, FunctionComponent } from 'react';
3import { Action, UnknownAction, Store, Dispatch } from 'redux';
4
5/**
6 * Copyright 2015, Yahoo! Inc.
7 * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
8 */
9
10declare const REACT_STATICS: {
11 readonly childContextTypes: true;
12 readonly contextType: true;
13 readonly contextTypes: true;
14 readonly defaultProps: true;
15 readonly displayName: true;
16 readonly getDefaultProps: true;
17 readonly getDerivedStateFromError: true;
18 readonly getDerivedStateFromProps: true;
19 readonly mixins: true;
20 readonly propTypes: true;
21 readonly type: true;
22};
23declare const KNOWN_STATICS: {
24 readonly name: true;
25 readonly length: true;
26 readonly prototype: true;
27 readonly caller: true;
28 readonly callee: true;
29 readonly arguments: true;
30 readonly arity: true;
31};
32declare const FORWARD_REF_STATICS: {
33 readonly $$typeof: true;
34 readonly render: true;
35 readonly defaultProps: true;
36 readonly displayName: true;
37 readonly propTypes: true;
38};
39declare const MEMO_STATICS: {
40 readonly $$typeof: true;
41 readonly compare: true;
42 readonly defaultProps: true;
43 readonly displayName: true;
44 readonly propTypes: true;
45 readonly type: true;
46};
47type NonReactStatics<S extends React$1.ComponentType<any>, C extends {
48 [key: string]: true;
49} = {}> = {
50 [key in Exclude<keyof S, S extends React$1.MemoExoticComponent<any> ? keyof typeof MEMO_STATICS | keyof C : S extends React$1.ForwardRefExoticComponent<any> ? keyof typeof FORWARD_REF_STATICS | keyof C : keyof typeof REACT_STATICS | keyof typeof KNOWN_STATICS | keyof C>]: S[key];
51};
52
53type VoidFunc = () => void;
54type Listener = {
55 callback: VoidFunc;
56 next: Listener | null;
57 prev: Listener | null;
58};
59declare function createListenerCollection(): {
60 clear(): void;
61 notify(): void;
62 get(): Listener[];
63 subscribe(callback: () => void): () => void;
64};
65type ListenerCollection = ReturnType<typeof createListenerCollection>;
66interface Subscription {
67 addNestedSub: (listener: VoidFunc) => VoidFunc;
68 notifyNestedSubs: VoidFunc;
69 handleChangeWrapper: VoidFunc;
70 isSubscribed: () => boolean;
71 onStateChange?: VoidFunc | null;
72 trySubscribe: VoidFunc;
73 tryUnsubscribe: VoidFunc;
74 getListeners: () => ListenerCollection;
75}
76
77interface ProviderProps<A extends Action<string> = UnknownAction, S = unknown> {
78 /**
79 * The single Redux store in your application.
80 */
81 store: Store<S, A>;
82 /**
83 * 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.
84 */
85 serverState?: S;
86 /**
87 * Optional context to be used internally in react-redux. Use React.createContext() to create a context to be used.
88 * If this is used, you'll need to customize `connect` by supplying the same context provided to the Provider.
89 * Set the initial value to null, and the hooks will error
90 * if this is not overwritten by Provider.
91 */
92 context?: Context<ReactReduxContextValue<S, A> | null>;
93 /**
94 * Determines the frequency of stability checks for all selectors.
95 * This setting overrides the global configuration for
96 * the `useSelector` stability check, allowing you to specify how often
97 * these checks should occur in development mode.
98 *
99 * @since 8.1.0
100 */
101 stabilityCheck?: DevModeCheckFrequency;
102 /**
103 * Determines the frequency of identity function checks for all selectors.
104 * This setting overrides the global configuration for
105 * the `useSelector` identity function check, allowing you to specify how often
106 * these checks should occur in development mode.
107 *
108 * **Note**: Previously referred to as `noopCheck`.
109 *
110 * @since 9.0.0
111 */
112 identityFunctionCheck?: DevModeCheckFrequency;
113 children: ReactNode;
114}
115declare function Provider<A extends Action<string> = UnknownAction, S = unknown>({ store, context, children, serverState, stabilityCheck, identityFunctionCheck, }: ProviderProps<A, S>): React$1.JSX.Element;
116
117interface ReactReduxContextValue<SS = any, A extends Action<string> = UnknownAction> extends Pick<ProviderProps, 'stabilityCheck' | 'identityFunctionCheck'> {
118 store: Store<SS, A>;
119 subscription: Subscription;
120 getServerState?: () => SS;
121}
122declare const ReactReduxContext: Context<ReactReduxContextValue<any, UnknownAction> | null>;
123type ReactReduxContextInstance = typeof ReactReduxContext;
124
125/**
126 * The frequency of development mode checks.
127 *
128 * @since 8.1.0
129 * @internal
130 */
131type DevModeCheckFrequency = 'never' | 'once' | 'always';
132/**
133 * Represents the configuration for development mode checks.
134 *
135 * @since 9.0.0
136 * @internal
137 */
138interface DevModeChecks {
139 /**
140 * Overrides the global stability check for the selector.
141 * - `once` - Run only the first time the selector is called.
142 * - `always` - Run every time the selector is called.
143 * - `never` - Never run the stability check.
144 *
145 * @default 'once'
146 *
147 * @since 8.1.0
148 */
149 stabilityCheck: DevModeCheckFrequency;
150 /**
151 * Overrides the global identity function check for the selector.
152 * - `once` - Run only the first time the selector is called.
153 * - `always` - Run every time the selector is called.
154 * - `never` - Never run the identity function check.
155 *
156 * **Note**: Previously referred to as `noopCheck`.
157 *
158 * @default 'once'
159 *
160 * @since 9.0.0
161 */
162 identityFunctionCheck: DevModeCheckFrequency;
163}
164interface UseSelectorOptions<Selected = unknown> {
165 equalityFn?: EqualityFn<Selected>;
166 /**
167 * `useSelector` performs additional checks in development mode to help
168 * identify and warn about potential issues in selector behavior. This
169 * option allows you to customize the behavior of these checks per selector.
170 *
171 * @since 9.0.0
172 */
173 devModeChecks?: Partial<DevModeChecks>;
174}
175/**
176 * Represents a custom hook that allows you to extract data from the
177 * Redux store state, using a selector function. The selector function
178 * takes the current state as an argument and returns a part of the state
179 * or some derived data. The hook also supports an optional equality
180 * function or options object to customize its behavior.
181 *
182 * @template StateType - The specific type of state this hook operates on.
183 *
184 * @public
185 */
186interface UseSelector<StateType = unknown> {
187 /**
188 * A function that takes a selector function as its first argument.
189 * The selector function is responsible for selecting a part of
190 * the Redux store's state or computing derived data.
191 *
192 * @param selector - A function that receives the current state and returns a part of the state or some derived data.
193 * @param equalityFnOrOptions - An optional equality function or options object for customizing the behavior of the selector.
194 * @returns The selected part of the state or derived data.
195 *
196 * @template TState - The specific type of state this hook operates on.
197 * @template Selected - The type of the value that the selector function will return.
198 */
199 <TState extends StateType = StateType, Selected = unknown>(selector: (state: TState) => Selected, equalityFnOrOptions?: EqualityFn<Selected> | UseSelectorOptions<Selected>): Selected;
200 /**
201 * Creates a "pre-typed" version of {@linkcode useSelector useSelector}
202 * where the `state` type is predefined.
203 *
204 * This allows you to set the `state` type once, eliminating the need to
205 * specify it with every {@linkcode useSelector useSelector} call.
206 *
207 * @returns A pre-typed `useSelector` with the state type already defined.
208 *
209 * @example
210 * ```ts
211 * export const useAppSelector = useSelector.withTypes<RootState>()
212 * ```
213 *
214 * @template OverrideStateType - The specific type of state this hook operates on.
215 *
216 * @since 9.1.0
217 */
218 withTypes: <OverrideStateType extends StateType>() => UseSelector<OverrideStateType>;
219}
220/**
221 * Hook factory, which creates a `useSelector` hook bound to a given context.
222 *
223 * @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
224 * @returns {Function} A `useSelector` hook bound to the specified context.
225 */
226declare function createSelectorHook(context?: React.Context<ReactReduxContextValue<any, any> | null>): UseSelector;
227/**
228 * A hook to access the redux store's state. This hook takes a selector function
229 * as an argument. The selector is called with the store state.
230 *
231 * This hook takes an optional equality comparison function as the second parameter
232 * that allows you to customize the way the selected state is compared to determine
233 * whether the component needs to be re-rendered.
234 *
235 * @param {Function} selector the selector function
236 * @param {Function=} equalityFn the function that will be used to determine equality
237 *
238 * @returns {any} the selected state
239 *
240 * @example
241 *
242 * import React from 'react'
243 * import { useSelector } from 'react-redux'
244 *
245 * export const CounterComponent = () => {
246 * const counter = useSelector(state => state.counter)
247 * return <div>{counter}</div>
248 * }
249 */
250declare const useSelector: UseSelector<unknown>;
251
252type FixTypeLater = any;
253type EqualityFn<T> = (a: T, b: T) => boolean;
254type ExtendedEqualityFn<T, P> = (a: T, b: T, c: P, d: P) => boolean;
255type AnyIfEmpty<T extends object> = keyof T extends never ? any : T;
256type DistributiveOmit<T, K extends keyof T> = T extends unknown ? Omit<T, K> : never;
257interface DispatchProp<A extends Action<string> = UnknownAction> {
258 dispatch: Dispatch<A>;
259}
260/**
261 * A property P will be present if:
262 * - it is present in DecorationTargetProps
263 *
264 * Its value will be dependent on the following conditions
265 * - if property P is present in InjectedProps and its definition extends the definition
266 * in DecorationTargetProps, then its definition will be that of DecorationTargetProps[P]
267 * - if property P is not present in InjectedProps then its definition will be that of
268 * DecorationTargetProps[P]
269 * - if property P is present in InjectedProps but does not extend the
270 * DecorationTargetProps[P] definition, its definition will be that of InjectedProps[P]
271 */
272type Matching<InjectedProps, DecorationTargetProps> = {
273 [P in keyof DecorationTargetProps]: P extends keyof InjectedProps ? InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : InjectedProps[P] : DecorationTargetProps[P];
274};
275/**
276 * a property P will be present if :
277 * - it is present in both DecorationTargetProps and InjectedProps
278 * - InjectedProps[P] can satisfy DecorationTargetProps[P]
279 * ie: decorated component can accept more types than decorator is injecting
280 *
281 * For decoration, inject props or ownProps are all optionally
282 * required by the decorated (right hand side) component.
283 * But any property required by the decorated component must be satisfied by the injected property.
284 */
285type Shared<InjectedProps, DecorationTargetProps> = {
286 [P in Extract<keyof InjectedProps, keyof DecorationTargetProps>]?: InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : never;
287};
288type GetProps<C> = C extends ComponentType<infer P> ? C extends ComponentClass<P> ? ClassAttributes<InstanceType<C>> & P : P : never;
289type GetLibraryManagedProps<C> = JSX.LibraryManagedAttributes<C, GetProps<C>>;
290type ConnectedComponent<C extends ComponentType<any>, P> = FunctionComponent<P> & NonReactStatics<C> & {
291 WrappedComponent: C;
292};
293type ConnectPropsMaybeWithoutContext<TActualOwnProps> = TActualOwnProps extends {
294 context: any;
295} ? Omit<ConnectProps, 'context'> : ConnectProps;
296type Identity<T> = T;
297type Mapped<T> = Identity<{
298 [k in keyof T]: T[k];
299}>;
300type 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>>>>;
301type InferableComponentEnhancer<TInjectedProps> = InferableComponentEnhancerWithProps<TInjectedProps, {}>;
302type InferThunkActionCreatorType<TActionCreator extends (...args: any[]) => any> = TActionCreator extends (...args: infer TParams) => (...args: any[]) => infer TReturn ? (...args: TParams) => TReturn : TActionCreator;
303type HandleThunkActionCreator<TActionCreator> = TActionCreator extends (...args: any[]) => any ? InferThunkActionCreatorType<TActionCreator> : TActionCreator;
304type ResolveThunks<TDispatchProps> = TDispatchProps extends {
305 [key: string]: any;
306} ? {
307 [C in keyof TDispatchProps]: HandleThunkActionCreator<TDispatchProps[C]>;
308} : TDispatchProps;
309/**
310 * This interface allows you to easily create a hook that is properly typed for your
311 * store's root state.
312 *
313 * @example
314 *
315 * interface RootState {
316 * property: string;
317 * }
318 *
319 * const useTypedSelector: TypedUseSelectorHook<RootState> = useSelector;
320 */
321interface TypedUseSelectorHook<TState> {
322 <TSelected>(selector: (state: TState) => TSelected, equalityFn?: EqualityFn<NoInfer<TSelected>>): TSelected;
323 <Selected = unknown>(selector: (state: TState) => Selected, options?: UseSelectorOptions<Selected>): Selected;
324}
325type NoInfer<T> = [T][T extends any ? 0 : never];
326
327type SelectorFactory<S, TProps, TOwnProps, TFactoryOptions> = (dispatch: Dispatch<Action<string>>, factoryOptions: TFactoryOptions) => Selector<S, TProps, TOwnProps>;
328type Selector<S, TProps, TOwnProps = null> = TOwnProps extends null | undefined ? (state: S) => TProps : (state: S, ownProps: TOwnProps) => TProps;
329type MapStateToProps<TStateProps, TOwnProps, State> = (state: State, ownProps: TOwnProps) => TStateProps;
330type MapStateToPropsFactory<TStateProps, TOwnProps, State> = (initialState: State, ownProps: TOwnProps) => MapStateToProps<TStateProps, TOwnProps, State>;
331type MapStateToPropsParam<TStateProps, TOwnProps, State> = MapStateToPropsFactory<TStateProps, TOwnProps, State> | MapStateToProps<TStateProps, TOwnProps, State> | null | undefined;
332type MapDispatchToPropsFunction<TDispatchProps, TOwnProps> = (dispatch: Dispatch<Action<string>>, ownProps: TOwnProps) => TDispatchProps;
333type MapDispatchToProps<TDispatchProps, TOwnProps> = MapDispatchToPropsFunction<TDispatchProps, TOwnProps> | TDispatchProps;
334type MapDispatchToPropsFactory<TDispatchProps, TOwnProps> = (dispatch: Dispatch<Action<string>>, ownProps: TOwnProps) => MapDispatchToPropsFunction<TDispatchProps, TOwnProps>;
335type MapDispatchToPropsParam<TDispatchProps, TOwnProps> = MapDispatchToPropsFactory<TDispatchProps, TOwnProps> | MapDispatchToProps<TDispatchProps, TOwnProps>;
336type MapDispatchToPropsNonObject<TDispatchProps, TOwnProps> = MapDispatchToPropsFactory<TDispatchProps, TOwnProps> | MapDispatchToPropsFunction<TDispatchProps, TOwnProps>;
337type MergeProps<TStateProps, TDispatchProps, TOwnProps, TMergedProps> = (stateProps: TStateProps, dispatchProps: TDispatchProps, ownProps: TOwnProps) => TMergedProps;
338
339interface ConnectProps {
340 /** A custom Context instance that the component can use to access the store from an alternate Provider using that same Context instance */
341 context?: ReactReduxContextInstance;
342 /** A Redux store instance to be used for subscriptions instead of the store from a Provider */
343 store?: Store;
344}
345/**
346 * Infers the type of props that a connector will inject into a component.
347 */
348type ConnectedProps<TConnector> = TConnector extends InferableComponentEnhancerWithProps<infer TInjectedProps, any> ? unknown extends TInjectedProps ? TConnector extends InferableComponentEnhancer<infer TInjectedProps> ? TInjectedProps : never : TInjectedProps : never;
349interface ConnectOptions<State = unknown, TStateProps = {}, TOwnProps = {}, TMergedProps = {}> {
350 forwardRef?: boolean;
351 context?: typeof ReactReduxContext;
352 areStatesEqual?: (nextState: State, prevState: State, nextOwnProps: TOwnProps, prevOwnProps: TOwnProps) => boolean;
353 areOwnPropsEqual?: (nextOwnProps: TOwnProps, prevOwnProps: TOwnProps) => boolean;
354 areStatePropsEqual?: (nextStateProps: TStateProps, prevStateProps: TStateProps) => boolean;
355 areMergedPropsEqual?: (nextMergedProps: TMergedProps, prevMergedProps: TMergedProps) => boolean;
356}
357/**
358 * Connects a React component to a Redux store.
359 *
360 * - Without arguments, just wraps the component, without changing the behavior / props
361 *
362 * - If 2 params are passed (3rd param, mergeProps, is skipped), default behavior
363 * is to override ownProps (as stated in the docs), so what remains is everything that's
364 * not a state or dispatch prop
365 *
366 * - When 3rd param is passed, we don't know if ownProps propagate and whether they
367 * should be valid component props, because it depends on mergeProps implementation.
368 * As such, it is the user's responsibility to extend ownProps interface from state or
369 * dispatch props or both when applicable
370 *
371 * @param mapStateToProps
372 * @param mapDispatchToProps
373 * @param mergeProps
374 * @param options
375 */
376interface Connect<DefaultState = unknown> {
377 (): InferableComponentEnhancer<DispatchProp>;
378 /** mapState only */
379 <TStateProps = {}, no_dispatch = {}, TOwnProps = {}, State = DefaultState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>): InferableComponentEnhancerWithProps<TStateProps & DispatchProp, TOwnProps>;
380 /** mapDispatch only (as a function) */
381 <no_state = {}, TDispatchProps = {}, TOwnProps = {}>(mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>): InferableComponentEnhancerWithProps<TDispatchProps, TOwnProps>;
382 /** mapDispatch only (as an object) */
383 <no_state = {}, TDispatchProps = {}, TOwnProps = {}>(mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>): InferableComponentEnhancerWithProps<ResolveThunks<TDispatchProps>, TOwnProps>;
384 /** mapState and mapDispatch (as a function)*/
385 <TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, State = DefaultState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>): InferableComponentEnhancerWithProps<TStateProps & TDispatchProps, TOwnProps>;
386 /** mapState and mapDispatch (nullish) */
387 <TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, State = DefaultState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: null | undefined): InferableComponentEnhancerWithProps<TStateProps, TOwnProps>;
388 /** mapState and mapDispatch (as an object) */
389 <TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, State = DefaultState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>): InferableComponentEnhancerWithProps<TStateProps & ResolveThunks<TDispatchProps>, TOwnProps>;
390 /** mergeProps only */
391 <no_state = {}, no_dispatch = {}, TOwnProps = {}, TMergedProps = {}>(mapStateToProps: null | undefined, mapDispatchToProps: null | undefined, mergeProps: MergeProps<undefined, DispatchProp, TOwnProps, TMergedProps>): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>;
392 /** mapState and mergeProps */
393 <TStateProps = {}, no_dispatch = {}, TOwnProps = {}, TMergedProps = {}, State = DefaultState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: null | undefined, mergeProps: MergeProps<TStateProps, DispatchProp, TOwnProps, TMergedProps>): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>;
394 /** mapDispatch (as a object) and mergeProps */
395 <no_state = {}, TDispatchProps = {}, TOwnProps = {}, TMergedProps = {}>(mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>, mergeProps: MergeProps<undefined, TDispatchProps, TOwnProps, TMergedProps>): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>;
396 /** mapState and options */
397 <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>;
398 /** mapDispatch (as a function) and options */
399 <TStateProps = {}, TDispatchProps = {}, TOwnProps = {}>(mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>, mergeProps: null | undefined, options: ConnectOptions<{}, TStateProps, TOwnProps>): InferableComponentEnhancerWithProps<TDispatchProps, TOwnProps>;
400 /** mapDispatch (as an object) and options*/
401 <TStateProps = {}, TDispatchProps = {}, TOwnProps = {}>(mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>, mergeProps: null | undefined, options: ConnectOptions<{}, TStateProps, TOwnProps>): InferableComponentEnhancerWithProps<ResolveThunks<TDispatchProps>, TOwnProps>;
402 /** mapState, mapDispatch (as a function), and options */
403 <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>;
404 /** mapState, mapDispatch (as an object), and options */
405 <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>;
406 /** mapState, mapDispatch, mergeProps, and options */
407 <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>;
408}
409declare const _default: Connect<unknown>;
410
411declare function shallowEqual(objA: any, objB: any): boolean;
412
413declare function defaultNoopBatch(callback: () => void): void;
414
415/**
416 * Represents a custom hook that provides a dispatch function
417 * from the Redux store.
418 *
419 * @template DispatchType - The specific type of the dispatch function.
420 *
421 * @since 9.1.0
422 * @public
423 */
424interface UseDispatch<DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> {
425 /**
426 * Returns the dispatch function from the Redux store.
427 *
428 * @returns The dispatch function from the Redux store.
429 *
430 * @template AppDispatch - The specific type of the dispatch function.
431 */
432 <AppDispatch extends DispatchType = DispatchType>(): AppDispatch;
433 /**
434 * Creates a "pre-typed" version of {@linkcode useDispatch useDispatch}
435 * where the type of the `dispatch` function is predefined.
436 *
437 * This allows you to set the `dispatch` type once, eliminating the need to
438 * specify it with every {@linkcode useDispatch useDispatch} call.
439 *
440 * @returns A pre-typed `useDispatch` with the dispatch type already defined.
441 *
442 * @example
443 * ```ts
444 * export const useAppDispatch = useDispatch.withTypes<AppDispatch>()
445 * ```
446 *
447 * @template OverrideDispatchType - The specific type of the dispatch function.
448 *
449 * @since 9.1.0
450 */
451 withTypes: <OverrideDispatchType extends DispatchType>() => UseDispatch<OverrideDispatchType>;
452}
453/**
454 * Hook factory, which creates a `useDispatch` hook bound to a given context.
455 *
456 * @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
457 * @returns {Function} A `useDispatch` hook bound to the specified context.
458 */
459declare function createDispatchHook<StateType = unknown, ActionType extends Action = UnknownAction>(context?: Context<ReactReduxContextValue<StateType, ActionType> | null>): UseDispatch<Dispatch<ActionType>>;
460/**
461 * A hook to access the redux `dispatch` function.
462 *
463 * @returns {any|function} redux store's `dispatch` function
464 *
465 * @example
466 *
467 * import React, { useCallback } from 'react'
468 * import { useDispatch } from 'react-redux'
469 *
470 * export const CounterComponent = ({ value }) => {
471 * const dispatch = useDispatch()
472 * const increaseCounter = useCallback(() => dispatch({ type: 'increase-counter' }), [])
473 * return (
474 * <div>
475 * <span>{value}</span>
476 * <button onClick={increaseCounter}>Increase counter</button>
477 * </div>
478 * )
479 * }
480 */
481declare const useDispatch: UseDispatch<Dispatch<UnknownAction>>;
482
483/**
484 * Represents a type that extracts the action type from a given Redux store.
485 *
486 * @template StoreType - The specific type of the Redux store.
487 *
488 * @since 9.1.0
489 * @internal
490 */
491type ExtractStoreActionType<StoreType extends Store> = StoreType extends Store<any, infer ActionType> ? ActionType : never;
492/**
493 * Represents a custom hook that provides access to the Redux store.
494 *
495 * @template StoreType - The specific type of the Redux store that gets returned.
496 *
497 * @since 9.1.0
498 * @public
499 */
500interface UseStore<StoreType extends Store> {
501 /**
502 * Returns the Redux store instance.
503 *
504 * @returns The Redux store instance.
505 */
506 (): StoreType;
507 /**
508 * Returns the Redux store instance with specific state and action types.
509 *
510 * @returns The Redux store with the specified state and action types.
511 *
512 * @template StateType - The specific type of the state used in the store.
513 * @template ActionType - The specific type of the actions used in the store.
514 */
515 <StateType extends ReturnType<StoreType['getState']> = ReturnType<StoreType['getState']>, ActionType extends Action = ExtractStoreActionType<Store>>(): Store<StateType, ActionType>;
516 /**
517 * Creates a "pre-typed" version of {@linkcode useStore useStore}
518 * where the type of the Redux `store` is predefined.
519 *
520 * This allows you to set the `store` type once, eliminating the need to
521 * specify it with every {@linkcode useStore useStore} call.
522 *
523 * @returns A pre-typed `useStore` with the store type already defined.
524 *
525 * @example
526 * ```ts
527 * export const useAppStore = useStore.withTypes<AppStore>()
528 * ```
529 *
530 * @template OverrideStoreType - The specific type of the Redux store that gets returned.
531 *
532 * @since 9.1.0
533 */
534 withTypes: <OverrideStoreType extends StoreType>() => UseStore<OverrideStoreType>;
535}
536/**
537 * Hook factory, which creates a `useStore` hook bound to a given context.
538 *
539 * @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
540 * @returns {Function} A `useStore` hook bound to the specified context.
541 */
542declare function createStoreHook<StateType = unknown, ActionType extends Action = Action>(context?: Context<ReactReduxContextValue<StateType, ActionType> | null>): UseStore<Store<StateType, ActionType, {}>>;
543/**
544 * A hook to access the redux store.
545 *
546 * @returns {any} the redux store
547 *
548 * @example
549 *
550 * import React from 'react'
551 * import { useStore } from 'react-redux'
552 *
553 * export const ExampleComponent = () => {
554 * const store = useStore()
555 * return <div>{store.getState()}</div>
556 * }
557 */
558declare const useStore: UseStore<Store<unknown, Action, {}>>;
559
560/**
561 * @deprecated As of React 18, batching is enabled by default for ReactDOM and React Native.
562 * This is now a no-op that immediately runs the callback.
563 */
564declare const batch: typeof defaultNoopBatch;
565
566export { AnyIfEmpty, Connect, ConnectProps, ConnectPropsMaybeWithoutContext, ConnectedComponent, ConnectedProps, DispatchProp, DistributiveOmit, EqualityFn, ExtendedEqualityFn, FixTypeLater, GetLibraryManagedProps, GetProps, HandleThunkActionCreator, InferThunkActionCreatorType, InferableComponentEnhancer, InferableComponentEnhancerWithProps, MapDispatchToProps, MapDispatchToPropsFactory, MapDispatchToPropsFunction, MapDispatchToPropsNonObject, MapDispatchToPropsParam, MapStateToProps, MapStateToPropsFactory, MapStateToPropsParam, Mapped, Matching, MergeProps, NoInfer, Provider, ProviderProps, ReactReduxContext, ReactReduxContextValue, ResolveThunks, Selector, SelectorFactory, Shared, Subscription, TypedUseSelectorHook, UseDispatch, UseSelector, UseStore, batch, _default as connect, createDispatchHook, createSelectorHook, createStoreHook, shallowEqual, useDispatch, useSelector, useStore };