import * as React$1 from 'react'; import { Context, ReactNode, ComponentType, ComponentClass, ClassAttributes, JSX, FunctionComponent } from 'react'; import { Action, UnknownAction, Store, Dispatch } from 'redux'; /** * Copyright 2015, Yahoo! Inc. * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. */ declare const REACT_STATICS: { readonly childContextTypes: true; readonly contextType: true; readonly contextTypes: true; readonly defaultProps: true; readonly displayName: true; readonly getDefaultProps: true; readonly getDerivedStateFromError: true; readonly getDerivedStateFromProps: true; readonly mixins: true; readonly propTypes: true; readonly type: true; }; declare const KNOWN_STATICS: { readonly name: true; readonly length: true; readonly prototype: true; readonly caller: true; readonly callee: true; readonly arguments: true; readonly arity: true; }; declare const FORWARD_REF_STATICS: { readonly $$typeof: true; readonly render: true; readonly defaultProps: true; readonly displayName: true; readonly propTypes: true; }; declare const MEMO_STATICS: { readonly $$typeof: true; readonly compare: true; readonly defaultProps: true; readonly displayName: true; readonly propTypes: true; readonly type: true; }; type NonReactStatics, C extends { [key: string]: true; } = {}> = { [key in Exclude ? keyof typeof MEMO_STATICS | keyof C : S extends React$1.ForwardRefExoticComponent ? keyof typeof FORWARD_REF_STATICS | keyof C : keyof typeof REACT_STATICS | keyof typeof KNOWN_STATICS | keyof C>]: S[key]; }; type VoidFunc = () => void; type Listener = { callback: VoidFunc; next: Listener | null; prev: Listener | null; }; declare function createListenerCollection(): { clear(): void; notify(): void; get(): Listener[]; subscribe(callback: () => void): () => void; }; type ListenerCollection = ReturnType; interface Subscription { addNestedSub: (listener: VoidFunc) => VoidFunc; notifyNestedSubs: VoidFunc; handleChangeWrapper: VoidFunc; isSubscribed: () => boolean; onStateChange?: VoidFunc | null; trySubscribe: VoidFunc; tryUnsubscribe: VoidFunc; getListeners: () => ListenerCollection; } interface ProviderProps = UnknownAction, S = unknown> { /** * The single Redux store in your application. */ store: Store; /** * 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. */ serverState?: S; /** * Optional context to be used internally in react-redux. Use React.createContext() to create a context to be used. * If this is used, you'll need to customize `connect` by supplying the same context provided to the Provider. * Set the initial value to null, and the hooks will error * if this is not overwritten by Provider. */ context?: Context | null>; /** * Determines the frequency of stability checks for all selectors. * This setting overrides the global configuration for * the `useSelector` stability check, allowing you to specify how often * these checks should occur in development mode. * * @since 8.1.0 */ stabilityCheck?: DevModeCheckFrequency; /** * Determines the frequency of identity function checks for all selectors. * This setting overrides the global configuration for * the `useSelector` identity function check, allowing you to specify how often * these checks should occur in development mode. * * **Note**: Previously referred to as `noopCheck`. * * @since 9.0.0 */ identityFunctionCheck?: DevModeCheckFrequency; children: ReactNode; } declare function Provider = UnknownAction, S = unknown>({ store, context, children, serverState, stabilityCheck, identityFunctionCheck, }: ProviderProps): React$1.JSX.Element; interface ReactReduxContextValue = UnknownAction> extends Pick { store: Store; subscription: Subscription; getServerState?: () => SS; } declare const ReactReduxContext: Context | null>; type ReactReduxContextInstance = typeof ReactReduxContext; /** * The frequency of development mode checks. * * @since 8.1.0 * @internal */ type DevModeCheckFrequency = 'never' | 'once' | 'always'; /** * Represents the configuration for development mode checks. * * @since 9.0.0 * @internal */ interface DevModeChecks { /** * Overrides the global stability check for the selector. * - `once` - Run only the first time the selector is called. * - `always` - Run every time the selector is called. * - `never` - Never run the stability check. * * @default 'once' * * @since 8.1.0 */ stabilityCheck: DevModeCheckFrequency; /** * Overrides the global identity function check for the selector. * - `once` - Run only the first time the selector is called. * - `always` - Run every time the selector is called. * - `never` - Never run the identity function check. * * **Note**: Previously referred to as `noopCheck`. * * @default 'once' * * @since 9.0.0 */ identityFunctionCheck: DevModeCheckFrequency; } interface UseSelectorOptions { equalityFn?: EqualityFn; /** * `useSelector` performs additional checks in development mode to help * identify and warn about potential issues in selector behavior. This * option allows you to customize the behavior of these checks per selector. * * @since 9.0.0 */ devModeChecks?: Partial; } /** * Represents a custom hook that allows you to extract data from the * Redux store state, using a selector function. The selector function * takes the current state as an argument and returns a part of the state * or some derived data. The hook also supports an optional equality * function or options object to customize its behavior. * * @template StateType - The specific type of state this hook operates on. * * @public */ interface UseSelector { /** * A function that takes a selector function as its first argument. * The selector function is responsible for selecting a part of * the Redux store's state or computing derived data. * * @param selector - A function that receives the current state and returns a part of the state or some derived data. * @param equalityFnOrOptions - An optional equality function or options object for customizing the behavior of the selector. * @returns The selected part of the state or derived data. * * @template TState - The specific type of state this hook operates on. * @template Selected - The type of the value that the selector function will return. */ (selector: (state: TState) => Selected, equalityFnOrOptions?: EqualityFn | UseSelectorOptions): Selected; /** * Creates a "pre-typed" version of {@linkcode useSelector useSelector} * where the `state` type is predefined. * * This allows you to set the `state` type once, eliminating the need to * specify it with every {@linkcode useSelector useSelector} call. * * @returns A pre-typed `useSelector` with the state type already defined. * * @example * ```ts * export const useAppSelector = useSelector.withTypes() * ``` * * @template OverrideStateType - The specific type of state this hook operates on. * * @since 9.1.0 */ withTypes: () => UseSelector; } /** * Hook factory, which creates a `useSelector` hook bound to a given context. * * @param {React.Context} [context=ReactReduxContext] Context passed to your ``. * @returns {Function} A `useSelector` hook bound to the specified context. */ declare function createSelectorHook(context?: React.Context | null>): UseSelector; /** * A hook to access the redux store's state. This hook takes a selector function * as an argument. The selector is called with the store state. * * This hook takes an optional equality comparison function as the second parameter * that allows you to customize the way the selected state is compared to determine * whether the component needs to be re-rendered. * * @param {Function} selector the selector function * @param {Function=} equalityFn the function that will be used to determine equality * * @returns {any} the selected state * * @example * * import React from 'react' * import { useSelector } from 'react-redux' * * export const CounterComponent = () => { * const counter = useSelector(state => state.counter) * return
{counter}
* } */ declare const useSelector: UseSelector; type FixTypeLater = any; type EqualityFn = (a: T, b: T) => boolean; type ExtendedEqualityFn = (a: T, b: T, c: P, d: P) => boolean; type AnyIfEmpty = keyof T extends never ? any : T; type DistributiveOmit = T extends unknown ? Omit : never; interface DispatchProp
= UnknownAction> { dispatch: Dispatch; } /** * A property P will be present if: * - it is present in DecorationTargetProps * * Its value will be dependent on the following conditions * - if property P is present in InjectedProps and its definition extends the definition * in DecorationTargetProps, then its definition will be that of DecorationTargetProps[P] * - if property P is not present in InjectedProps then its definition will be that of * DecorationTargetProps[P] * - if property P is present in InjectedProps but does not extend the * DecorationTargetProps[P] definition, its definition will be that of InjectedProps[P] */ type Matching = { [P in keyof DecorationTargetProps]: P extends keyof InjectedProps ? InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : InjectedProps[P] : DecorationTargetProps[P]; }; /** * a property P will be present if : * - it is present in both DecorationTargetProps and InjectedProps * - InjectedProps[P] can satisfy DecorationTargetProps[P] * ie: decorated component can accept more types than decorator is injecting * * For decoration, inject props or ownProps are all optionally * required by the decorated (right hand side) component. * But any property required by the decorated component must be satisfied by the injected property. */ type Shared = { [P in Extract]?: InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : never; }; type GetProps = C extends ComponentType ? C extends ComponentClass

? ClassAttributes> & P : P : never; type GetLibraryManagedProps = JSX.LibraryManagedAttributes>; type ConnectedComponent, P> = FunctionComponent

& NonReactStatics & { WrappedComponent: C; }; type ConnectPropsMaybeWithoutContext = TActualOwnProps extends { context: any; } ? Omit : ConnectProps; type Identity = T; type Mapped = Identity<{ [k in keyof T]: T[k]; }>; type InferableComponentEnhancerWithProps = >>>(component: C) => ConnectedComponent, keyof Shared>> & TNeedsProps & ConnectPropsMaybeWithoutContext>>>; type InferableComponentEnhancer = InferableComponentEnhancerWithProps; type InferThunkActionCreatorType any> = TActionCreator extends (...args: infer TParams) => (...args: any[]) => infer TReturn ? (...args: TParams) => TReturn : TActionCreator; type HandleThunkActionCreator = TActionCreator extends (...args: any[]) => any ? InferThunkActionCreatorType : TActionCreator; type ResolveThunks = TDispatchProps extends { [key: string]: any; } ? { [C in keyof TDispatchProps]: HandleThunkActionCreator; } : TDispatchProps; /** * This interface allows you to easily create a hook that is properly typed for your * store's root state. * * @example * * interface RootState { * property: string; * } * * const useTypedSelector: TypedUseSelectorHook = useSelector; */ interface TypedUseSelectorHook { (selector: (state: TState) => TSelected, equalityFn?: EqualityFn>): TSelected; (selector: (state: TState) => Selected, options?: UseSelectorOptions): Selected; } type NoInfer = [T][T extends any ? 0 : never]; type SelectorFactory = (dispatch: Dispatch>, factoryOptions: TFactoryOptions) => Selector; type Selector = TOwnProps extends null | undefined ? (state: S) => TProps : (state: S, ownProps: TOwnProps) => TProps; type MapStateToProps = (state: State, ownProps: TOwnProps) => TStateProps; type MapStateToPropsFactory = (initialState: State, ownProps: TOwnProps) => MapStateToProps; type MapStateToPropsParam = MapStateToPropsFactory | MapStateToProps | null | undefined; type MapDispatchToPropsFunction = (dispatch: Dispatch>, ownProps: TOwnProps) => TDispatchProps; type MapDispatchToProps = MapDispatchToPropsFunction | TDispatchProps; type MapDispatchToPropsFactory = (dispatch: Dispatch>, ownProps: TOwnProps) => MapDispatchToPropsFunction; type MapDispatchToPropsParam = MapDispatchToPropsFactory | MapDispatchToProps; type MapDispatchToPropsNonObject = MapDispatchToPropsFactory | MapDispatchToPropsFunction; type MergeProps = (stateProps: TStateProps, dispatchProps: TDispatchProps, ownProps: TOwnProps) => TMergedProps; interface ConnectProps { /** A custom Context instance that the component can use to access the store from an alternate Provider using that same Context instance */ context?: ReactReduxContextInstance; /** A Redux store instance to be used for subscriptions instead of the store from a Provider */ store?: Store; } /** * Infers the type of props that a connector will inject into a component. */ type ConnectedProps = TConnector extends InferableComponentEnhancerWithProps ? unknown extends TInjectedProps ? TConnector extends InferableComponentEnhancer ? TInjectedProps : never : TInjectedProps : never; interface ConnectOptions { forwardRef?: boolean; context?: typeof ReactReduxContext; areStatesEqual?: (nextState: State, prevState: State, nextOwnProps: TOwnProps, prevOwnProps: TOwnProps) => boolean; areOwnPropsEqual?: (nextOwnProps: TOwnProps, prevOwnProps: TOwnProps) => boolean; areStatePropsEqual?: (nextStateProps: TStateProps, prevStateProps: TStateProps) => boolean; areMergedPropsEqual?: (nextMergedProps: TMergedProps, prevMergedProps: TMergedProps) => boolean; } /** * Connects a React component to a Redux store. * * - Without arguments, just wraps the component, without changing the behavior / props * * - If 2 params are passed (3rd param, mergeProps, is skipped), default behavior * is to override ownProps (as stated in the docs), so what remains is everything that's * not a state or dispatch prop * * - When 3rd param is passed, we don't know if ownProps propagate and whether they * should be valid component props, because it depends on mergeProps implementation. * As such, it is the user's responsibility to extend ownProps interface from state or * dispatch props or both when applicable * * @param mapStateToProps * @param mapDispatchToProps * @param mergeProps * @param options */ interface Connect { (): InferableComponentEnhancer; /** mapState only */ (mapStateToProps: MapStateToPropsParam): InferableComponentEnhancerWithProps; /** mapDispatch only (as a function) */ (mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsNonObject): InferableComponentEnhancerWithProps; /** mapDispatch only (as an object) */ (mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam): InferableComponentEnhancerWithProps, TOwnProps>; /** mapState and mapDispatch (as a function)*/ (mapStateToProps: MapStateToPropsParam, mapDispatchToProps: MapDispatchToPropsNonObject): InferableComponentEnhancerWithProps; /** mapState and mapDispatch (nullish) */ (mapStateToProps: MapStateToPropsParam, mapDispatchToProps: null | undefined): InferableComponentEnhancerWithProps; /** mapState and mapDispatch (as an object) */ (mapStateToProps: MapStateToPropsParam, mapDispatchToProps: MapDispatchToPropsParam): InferableComponentEnhancerWithProps, TOwnProps>; /** mergeProps only */ (mapStateToProps: null | undefined, mapDispatchToProps: null | undefined, mergeProps: MergeProps): InferableComponentEnhancerWithProps; /** mapState and mergeProps */ (mapStateToProps: MapStateToPropsParam, mapDispatchToProps: null | undefined, mergeProps: MergeProps): InferableComponentEnhancerWithProps; /** mapDispatch (as a object) and mergeProps */ (mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam, mergeProps: MergeProps): InferableComponentEnhancerWithProps; /** mapState and options */ (mapStateToProps: MapStateToPropsParam, mapDispatchToProps: null | undefined, mergeProps: null | undefined, options: ConnectOptions): InferableComponentEnhancerWithProps; /** mapDispatch (as a function) and options */ (mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsNonObject, mergeProps: null | undefined, options: ConnectOptions<{}, TStateProps, TOwnProps>): InferableComponentEnhancerWithProps; /** mapDispatch (as an object) and options*/ (mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam, mergeProps: null | undefined, options: ConnectOptions<{}, TStateProps, TOwnProps>): InferableComponentEnhancerWithProps, TOwnProps>; /** mapState, mapDispatch (as a function), and options */ (mapStateToProps: MapStateToPropsParam, mapDispatchToProps: MapDispatchToPropsNonObject, mergeProps: null | undefined, options: ConnectOptions): InferableComponentEnhancerWithProps; /** mapState, mapDispatch (as an object), and options */ (mapStateToProps: MapStateToPropsParam, mapDispatchToProps: MapDispatchToPropsParam, mergeProps: null | undefined, options: ConnectOptions): InferableComponentEnhancerWithProps, TOwnProps>; /** mapState, mapDispatch, mergeProps, and options */ (mapStateToProps: MapStateToPropsParam, mapDispatchToProps: MapDispatchToPropsParam, mergeProps: MergeProps, options?: ConnectOptions): InferableComponentEnhancerWithProps; } declare const _default: Connect; declare function shallowEqual(objA: any, objB: any): boolean; declare function defaultNoopBatch(callback: () => void): void; /** * Represents a custom hook that provides a dispatch function * from the Redux store. * * @template DispatchType - The specific type of the dispatch function. * * @since 9.1.0 * @public */ interface UseDispatch = Dispatch> { /** * Returns the dispatch function from the Redux store. * * @returns The dispatch function from the Redux store. * * @template AppDispatch - The specific type of the dispatch function. */ (): AppDispatch; /** * Creates a "pre-typed" version of {@linkcode useDispatch useDispatch} * where the type of the `dispatch` function is predefined. * * This allows you to set the `dispatch` type once, eliminating the need to * specify it with every {@linkcode useDispatch useDispatch} call. * * @returns A pre-typed `useDispatch` with the dispatch type already defined. * * @example * ```ts * export const useAppDispatch = useDispatch.withTypes() * ``` * * @template OverrideDispatchType - The specific type of the dispatch function. * * @since 9.1.0 */ withTypes: () => UseDispatch; } /** * Hook factory, which creates a `useDispatch` hook bound to a given context. * * @param {React.Context} [context=ReactReduxContext] Context passed to your ``. * @returns {Function} A `useDispatch` hook bound to the specified context. */ declare function createDispatchHook(context?: Context | null>): UseDispatch>; /** * A hook to access the redux `dispatch` function. * * @returns {any|function} redux store's `dispatch` function * * @example * * import React, { useCallback } from 'react' * import { useDispatch } from 'react-redux' * * export const CounterComponent = ({ value }) => { * const dispatch = useDispatch() * const increaseCounter = useCallback(() => dispatch({ type: 'increase-counter' }), []) * return ( *

* {value} * *
* ) * } */ declare const useDispatch: UseDispatch>; /** * Represents a type that extracts the action type from a given Redux store. * * @template StoreType - The specific type of the Redux store. * * @since 9.1.0 * @internal */ type ExtractStoreActionType = StoreType extends Store ? ActionType : never; /** * Represents a custom hook that provides access to the Redux store. * * @template StoreType - The specific type of the Redux store that gets returned. * * @since 9.1.0 * @public */ interface UseStore { /** * Returns the Redux store instance. * * @returns The Redux store instance. */ (): StoreType; /** * Returns the Redux store instance with specific state and action types. * * @returns The Redux store with the specified state and action types. * * @template StateType - The specific type of the state used in the store. * @template ActionType - The specific type of the actions used in the store. */ = ReturnType, ActionType extends Action = ExtractStoreActionType>(): Store; /** * Creates a "pre-typed" version of {@linkcode useStore useStore} * where the type of the Redux `store` is predefined. * * This allows you to set the `store` type once, eliminating the need to * specify it with every {@linkcode useStore useStore} call. * * @returns A pre-typed `useStore` with the store type already defined. * * @example * ```ts * export const useAppStore = useStore.withTypes() * ``` * * @template OverrideStoreType - The specific type of the Redux store that gets returned. * * @since 9.1.0 */ withTypes: () => UseStore; } /** * Hook factory, which creates a `useStore` hook bound to a given context. * * @param {React.Context} [context=ReactReduxContext] Context passed to your ``. * @returns {Function} A `useStore` hook bound to the specified context. */ declare function createStoreHook(context?: Context | null>): UseStore>; /** * A hook to access the redux store. * * @returns {any} the redux store * * @example * * import React from 'react' * import { useStore } from 'react-redux' * * export const ExampleComponent = () => { * const store = useStore() * return
{store.getState()}
* } */ declare const useStore: UseStore>; /** * @deprecated As of React 18, batching is enabled by default for ReactDOM and React Native. * This is now a no-op that immediately runs the callback. */ declare const batch: typeof defaultNoopBatch; export { 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 };