UNPKG

react-redux

Version:

Official React bindings for Redux

39 lines (38 loc) 6.65 kB
import React from 'react'; import type { Store } from 'redux'; import type { DefaultRootState, InferableComponentEnhancer, InferableComponentEnhancerWithProps, ResolveThunks, DispatchProp } from '../types'; import { MapStateToPropsParam, MapDispatchToPropsParam, MergeProps, MapDispatchToPropsNonObject } from '../connect/selectorFactory'; import { ReactReduxContext, ReactReduxContextInstance } from './Context'; export interface ConnectProps { reactReduxForwardedRef?: React.ForwardedRef<unknown>; context?: ReactReduxContextInstance; store?: Store; } /** * Infers the type of props that a connector will inject into a component. */ export declare type ConnectedProps<TConnector> = TConnector extends InferableComponentEnhancerWithProps<infer TInjectedProps, any> ? unknown extends TInjectedProps ? TConnector extends InferableComponentEnhancer<infer TInjectedProps> ? TInjectedProps : never : TInjectedProps : never; export interface ConnectOptions<State = DefaultRootState, TStateProps = {}, TOwnProps = {}, TMergedProps = {}> { forwardRef?: boolean; context?: typeof ReactReduxContext; areStatesEqual?: (nextState: State, prevState: State) => boolean; areOwnPropsEqual?: (nextOwnProps: TOwnProps, prevOwnProps: TOwnProps) => boolean; areStatePropsEqual?: (nextStateProps: TStateProps, prevStateProps: TStateProps) => boolean; areMergedPropsEqual?: (nextMergedProps: TMergedProps, prevMergedProps: TMergedProps) => boolean; } declare function connect(): InferableComponentEnhancer<DispatchProp>; declare function connect<TStateProps = {}, no_dispatch = {}, TOwnProps = {}, State = DefaultRootState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>): InferableComponentEnhancerWithProps<TStateProps & DispatchProp, TOwnProps & ConnectProps>; declare function connect<no_state = {}, TDispatchProps = {}, TOwnProps = {}>(mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>): InferableComponentEnhancerWithProps<TDispatchProps, TOwnProps & ConnectProps>; declare function connect<no_state = {}, TDispatchProps = {}, TOwnProps = {}>(mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>): InferableComponentEnhancerWithProps<ResolveThunks<TDispatchProps>, TOwnProps & ConnectProps>; declare function connect<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, State = DefaultRootState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>): InferableComponentEnhancerWithProps<TStateProps & TDispatchProps, TOwnProps & ConnectProps>; declare function connect<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, State = DefaultRootState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>): InferableComponentEnhancerWithProps<TStateProps & ResolveThunks<TDispatchProps>, TOwnProps & ConnectProps>; declare function connect<no_state = {}, no_dispatch = {}, TOwnProps = {}, TMergedProps = {}>(mapStateToProps: null | undefined, mapDispatchToProps: null | undefined, mergeProps: MergeProps<undefined, undefined, TOwnProps, TMergedProps>): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps & ConnectProps>; declare function connect<TStateProps = {}, no_dispatch = {}, TOwnProps = {}, TMergedProps = {}, State = DefaultRootState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: null | undefined, mergeProps: MergeProps<TStateProps, undefined, TOwnProps, TMergedProps>): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps & ConnectProps>; declare function connect<no_state = {}, TDispatchProps = {}, TOwnProps = {}, TMergedProps = {}>(mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>, mergeProps: MergeProps<undefined, TDispatchProps, TOwnProps, TMergedProps>): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps & ConnectProps>; declare function connect<TStateProps = {}, no_dispatch = {}, TOwnProps = {}, State = DefaultRootState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: null | undefined, mergeProps: null | undefined, options: ConnectOptions<State, TStateProps, TOwnProps>): InferableComponentEnhancerWithProps<DispatchProp & TStateProps, TOwnProps & ConnectProps>; declare function connect<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}>(mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>, mergeProps: null | undefined, options: ConnectOptions<{}, TStateProps, TOwnProps>): InferableComponentEnhancerWithProps<TDispatchProps, TOwnProps & ConnectProps>; declare function connect<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}>(mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>, mergeProps: null | undefined, options: ConnectOptions<{}, TStateProps, TOwnProps>): InferableComponentEnhancerWithProps<ResolveThunks<TDispatchProps>, TOwnProps & ConnectProps>; declare function connect<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, State = DefaultRootState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>, mergeProps: null | undefined, options: ConnectOptions<State, TStateProps, TOwnProps>): InferableComponentEnhancerWithProps<TStateProps & TDispatchProps, TOwnProps & ConnectProps>; declare function connect<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, State = DefaultRootState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>, mergeProps: null | undefined, options: ConnectOptions<State, TStateProps, TOwnProps>): InferableComponentEnhancerWithProps<TStateProps & ResolveThunks<TDispatchProps>, TOwnProps & ConnectProps>; declare function connect<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, TMergedProps = {}, State = DefaultRootState>(mapStateToProps?: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps?: MapDispatchToPropsParam<TDispatchProps, TOwnProps>, mergeProps?: MergeProps<TStateProps, TDispatchProps, TOwnProps, TMergedProps>, options?: ConnectOptions<State, TStateProps, TOwnProps, TMergedProps>): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps & ConnectProps>; export default connect;