@types/react-redux
- Version 7.1.33
- Published
- 34.3 kB
- 4 dependencies
- MIT license
Install
npm i @types/react-redux
yarn add @types/react-redux
pnpm add @types/react-redux
Overview
TypeScript definitions for react-redux
Index
Variables
Functions
Classes
Interfaces
Type Aliases
- AdvancedComponentDecorator
- AnyIfEmpty
- ConnectedComponent
- ConnectedProps
- DistributiveOmit
- GetLibraryManagedProps
- GetProps
- HandleThunkActionCreator
- InferableComponentEnhancer
- InferableComponentEnhancerWithProps
- InferThunkActionCreatorType
- MapDispatchToProps
- MapDispatchToPropsFactory
- MapDispatchToPropsFunction
- MapDispatchToPropsNonObject
- MapDispatchToPropsParam
- MapStateToProps
- MapStateToPropsFactory
- MapStateToPropsParam
- Matching
- MergeProps
- Omit
- ResolveArrayThunks
- ResolveThunks
- RootStateOrAny
- Selector
- SelectorFactory
- Shared
Variables
variable connect
const connect: Connect<DefaultRootState>;
The connect function. See for details.
variable ReactReduxContext
const ReactReduxContext: Context<ReactReduxContextValue<any, AnyAction>>;
Exposes the internal context used in react-redux. It is generally advised to use the connect HOC to connect to the redux store instead of this approach.
Functions
function batch
batch: (cb: () => void) => void;
Wraps ReactDOM or React Native's internal unstable_batchedUpdate function. You can use it to ensure that multiple actions dispatched outside of React only result in a single render update.
function connectAdvanced
connectAdvanced: <S, TProps, TOwnProps, TFactoryOptions = {}>( selectorFactory: SelectorFactory<S, TProps, TOwnProps, TFactoryOptions>, connectOptions?: ConnectOptions & TFactoryOptions) => AdvancedComponentDecorator<TProps, TOwnProps>;
Connects a React component to a Redux store. It is the base for connect but is less opinionated about how to combine state, props, and dispatch into your final props. It makes no assumptions about defaults or memoization of results, leaving those responsibilities to the caller.It does not modify the component class passed to it; instead, it returns a new, connected component for you to use.
Parameter selectorFactory
The selector factory. See SelectorFactory type for details.
Parameter connectOptions
If specified, further customizes the behavior of the connector. Additionally, any extra options will be passed through to your selectorFactory in the factoryOptions argument.
function createDispatchHook
createDispatchHook: <S = any, A extends Action = AnyAction>( context?: Context<ReactReduxContextValue<S, A>>) => () => Dispatch<A>;
Hook factory, which creates a
useDispatch
hook bound to a given context.Parameter Context
passed to your
<Provider>
.Returns
A
useDispatch
hook bound to the specified context.
function createSelectorHook
createSelectorHook: <S = any, A extends Action = AnyAction>( context?: Context<ReactReduxContextValue<S, A>>) => <Selected extends unknown>( selector: (state: S) => Selected, equalityFn?: (previous: Selected, next: Selected) => boolean) => Selected;
Hook factory, which creates a
useSelector
hook bound to a given context.Parameter Context
passed to your
<Provider>
.Returns
A
useSelector
hook bound to the specified context.
function createStoreHook
createStoreHook: <S = any, A extends Action = AnyAction>( context?: Context<ReactReduxContextValue<S, A>>) => () => Store<S, A>;
Hook factory, which creates a
useStore
hook bound to a given context.Parameter Context
passed to your
<Provider>
.Returns
A
useStore
hook bound to the specified context.
function shallowEqual
shallowEqual: <T>(left: T, right: any) => boolean;
Compares two arbitrary values for shallow equality. Object values are compared based on their keys, i.e. they must have the same keys and for each key the value must be equal according to the
Object.is()
algorithm. Non-object values are also compared with the same algorithm asObject.is()
.
function useDispatch
useDispatch: { <TDispatch = Dispatch<any>>(): TDispatch; <A extends Action = AnyAction>(): Dispatch<A>;};
A hook to access the redux
dispatch
function.Note for
redux-thunk
users: the return type of the returneddispatch
functions for thunks is incorrect. However, it is possible to get a correctly typeddispatch
function by creating your own custom hook typed from the store's dispatch function like this:const useThunkDispatch = () => useDispatch<typeof store.dispatch>();
Returns
redux store's
dispatch
functionExample 1
import React from 'react' import { useDispatch } from 'react-redux'
export const CounterComponent = ({ value }) => { const dispatch = useDispatch() return ( {value} <button onClick={() => dispatch({ type: 'increase-counter' })}> Increase counter ) }
function useSelector
useSelector: <TState = DefaultRootState, TSelected = unknown>( selector: (state: TState) => TSelected, equalityFn?: (left: TSelected, right: TSelected) => boolean) => TSelected;
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.
If you do not want to have to specify the root state type for whenever you use this hook with an inline selector you can use the
TypedUseSelectorHook
interface to create a version of this hook that is properly typed for your root state.Parameter selector
the selector function
Parameter equalityFn
the function that will be used to determine equality
Returns
the selected state
Example 1
import React from 'react' import { useSelector } from 'react-redux' import { RootState } from './store'
export const CounterComponent = () => { const counter = useSelector((state: RootState) => state.counter) return {counter} }
function useStore
useStore: <S = any, A extends Action = AnyAction>() => Store<S, A>;
A hook to access the redux store.
Returns
the redux store
Example 1
import React from 'react' import { useStore } from 'react-redux'
export const ExampleComponent = () => { const store = useStore() return {store.getState()} }
Classes
class Provider
class Provider<A extends Action = AnyAction> extends Component<ProviderProps<A>> {}
Makes the Redux store available to the connect() calls in the component hierarchy below.
Interfaces
interface Connect
interface Connect<DefaultState = DefaultRootState> {}
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
Parameter mapStateToProps
Parameter mapDispatchToProps
Parameter mergeProps
Parameter options
call signature
(): InferableComponentEnhancer<DispatchProp>;
call signature
<TStateProps = {}, no_dispatch = {}, TOwnProps = {}, State = DefaultState>( mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>): InferableComponentEnhancerWithProps<TStateProps & DispatchProp, TOwnProps>;
call signature
<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}>( mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>, mergeProps: null | undefined, options: Options<{}, TStateProps, TOwnProps>): InferableComponentEnhancerWithProps<TDispatchProps, TOwnProps>;
call signature
<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}>( mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>, mergeProps: null | undefined, options: Options<{}, TStateProps, TOwnProps>): InferableComponentEnhancerWithProps<ResolveThunks<TDispatchProps>, TOwnProps>;
call signature
<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, State = DefaultState>( mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>, mergeProps: null | undefined, options: Options<State, TStateProps, TOwnProps>): InferableComponentEnhancerWithProps<TStateProps & TDispatchProps, TOwnProps>;
call signature
<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, State = DefaultState>( mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>, mergeProps: null | undefined, options: Options<State, TStateProps, TOwnProps>): InferableComponentEnhancerWithProps< TStateProps & ResolveThunks<TDispatchProps>, TOwnProps>;
call signature
< TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, TMergedProps = {}, State = DefaultState>( mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>, mergeProps: MergeProps<TStateProps, TDispatchProps, TOwnProps, TMergedProps>, options?: Options<State, TStateProps, TOwnProps, TMergedProps>): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>;
call signature
<no_state = {}, TDispatchProps = {}, TOwnProps = {}>( mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>): InferableComponentEnhancerWithProps<TDispatchProps, TOwnProps>;
call signature
<no_state = {}, TDispatchProps = {}, TOwnProps = {}>( mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>): InferableComponentEnhancerWithProps<ResolveThunks<TDispatchProps>, TOwnProps>;
call signature
<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, State = DefaultState>( mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>): InferableComponentEnhancerWithProps<TStateProps & TDispatchProps, TOwnProps>;
call signature
<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, State = DefaultState>( mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>): InferableComponentEnhancerWithProps< TStateProps & ResolveThunks<TDispatchProps>, TOwnProps>;
call signature
<no_state = {}, no_dispatch = {}, TOwnProps = {}, TMergedProps = {}>( mapStateToProps: null | undefined, mapDispatchToProps: null | undefined, mergeProps: MergeProps<undefined, DispatchProp, TOwnProps, TMergedProps>): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>;
call signature
< TStateProps = {}, no_dispatch = {}, TOwnProps = {}, TMergedProps = {}, State = DefaultState>( mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: null | undefined, mergeProps: MergeProps<TStateProps, DispatchProp, TOwnProps, TMergedProps>): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>;
call signature
<no_state = {}, TDispatchProps = {}, TOwnProps = {}, TMergedProps = {}>( mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>, mergeProps: MergeProps<undefined, TDispatchProps, TOwnProps, TMergedProps>): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>;
call signature
<TStateProps = {}, no_dispatch = {}, TOwnProps = {}, State = DefaultState>( mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: null | undefined, mergeProps: null | undefined, options: Options<State, TStateProps, TOwnProps>): InferableComponentEnhancerWithProps<DispatchProp & TStateProps, TOwnProps>;
interface ConnectOptions
interface ConnectOptions {}
property context
context?: Context<ReactReduxContextValue> | undefined;
The react context to get the store from.
ReactReduxContext
property getDisplayName
getDisplayName?: ((componentName: string) => string) | undefined;
Computes the connector component's displayName property relative to that of the wrapped component. Usually overridden by wrapper functions.
name => 'ConnectAdvanced('+name+')'
Parameter componentName
property methodName
methodName?: string | undefined;
Shown in error messages. Usually overridden by wrapper functions.
'connectAdvanced'
property renderCountProp
renderCountProp?: string | undefined;
If defined, a property named this value will be added to the props passed to the wrapped component. Its value will be the number of times the component has been rendered, which can be useful for tracking down unnecessary re-renders.
undefined
property shouldHandleStateChanges
shouldHandleStateChanges?: boolean | undefined;
Controls whether the connector component subscribes to redux store state changes. If set to false, it will only re-render on componentWillReceiveProps.
true
property storeKey
storeKey?: string | undefined;
The key of props/context to get the store. You probably only need this if you are in the inadvisable position of having multiple stores.
'store'
property withRef
withRef?: boolean | undefined;
Deprecated
Use forwardRef
false
interface DefaultRootState
interface DefaultRootState {}
This interface can be augmented by users to add default types for the root state when using
react-redux
. Use module augmentation to append your own type definition in a your_custom_type.d.ts file. https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
interface DispatchProp
interface DispatchProp<A extends Action = AnyAction> {}
property dispatch
dispatch: Dispatch<A>;
interface Options
interface Options< State = DefaultRootState, TStateProps = {}, TOwnProps = {}, TMergedProps = {}> extends ConnectOptions {}
property areMergedPropsEqual
areMergedPropsEqual?: | ((nextMergedProps: TMergedProps, prevMergedProps: TMergedProps) => boolean) | undefined;
When pure, compares the result of mergeProps to its previous value. shallowEqual
property areOwnPropsEqual
areOwnPropsEqual?: | ((nextOwnProps: TOwnProps, prevOwnProps: TOwnProps) => boolean) | undefined;
When pure, compares incoming props to its previous value. shallowEqual
property areStatePropsEqual
areStatePropsEqual?: | ((nextStateProps: TStateProps, prevStateProps: TStateProps) => boolean) | undefined;
When pure, compares the result of mapStateToProps to its previous value. shallowEqual
property areStatesEqual
areStatesEqual?: ((nextState: State, prevState: State) => boolean) | undefined;
When pure, compares incoming store state to its previous value. strictEqual
property forwardRef
forwardRef?: boolean | undefined;
If true, use React's forwardRef to expose a ref of the wrapped component
false
property pure
pure?: boolean | undefined;
If true, implements shouldComponentUpdate and shallowly compares the result of mergeProps, preventing unnecessary updates, assuming that the component is a “pure” component and does not rely on any input or state other than its props and the selected Redux store’s state. Defaults to true. true
interface ProviderProps
interface ProviderProps<A extends Action = AnyAction> {}
property children
children?: ReactNode;
property context
context?: Context<ReactReduxContextValue> | undefined;
Optional context to be used internally in react-redux. Use React.createContext() to create a context to be used. If this is used, generate own connect HOC by using connectAdvanced, supplying the same context provided to the Provider. Initial value doesn't matter, as it is overwritten with the internal state of Provider.
property store
store: Store<any, A>;
The single Redux store in your application.
interface ReactReduxContextValue
interface ReactReduxContextValue<SS = any, A extends Action = AnyAction> {}
property store
store: Store<SS, A>;
property storeState
storeState: SS;
interface TypedUseSelectorHook
interface TypedUseSelectorHook<TState> {}
This interface allows you to easily create a hook that is properly typed for your store's root state.
Example 1
interface RootState { property: string; }
const useTypedSelector: TypedUseSelectorHook = useSelector;
call signature
<TSelected>( selector: (state: TState) => TSelected, equalityFn?: (left: TSelected, right: TSelected) => boolean): TSelected;
Type Aliases
type AdvancedComponentDecorator
type AdvancedComponentDecorator<TProps, TOwnProps> = ( component: JSXElementConstructor<TProps>) => NamedExoticComponent<TOwnProps>;
type AnyIfEmpty
type AnyIfEmpty<T extends object> = keyof T extends never ? any : T;
type ConnectedComponent
type ConnectedComponent< C extends JSXElementConstructor<any>, P> = NamedExoticComponent<P> & hoistNonReactStatics.NonReactStatics<C> & { WrappedComponent: C; };
type ConnectedProps
type ConnectedProps<TConnector> = TConnector extends InferableComponentEnhancerWithProps<infer TInjectedProps, any> ? unknown extends TInjectedProps ? TConnector extends InferableComponentEnhancer<infer TInjectedProps> ? TInjectedProps : never : TInjectedProps : never;
Infers the type of props that a connector will inject into a component.
type DistributiveOmit
type DistributiveOmit<T, K extends keyof T> = T extends unknown ? Omit<T, K> : never;
type GetLibraryManagedProps
type GetLibraryManagedProps<C> = JSX.LibraryManagedAttributes<C, GetProps<C>>;
type GetProps
type GetProps<C> = C extends JSXElementConstructor<infer P> ? C extends ComponentClass<P> ? ClassAttributes<InstanceType<C>> & P : P : never;
type HandleThunkActionCreator
type HandleThunkActionCreator<TActionCreator> = TActionCreator extends ( ...args: any[]) => any ? InferThunkActionCreatorType<TActionCreator> : TActionCreator;
type InferableComponentEnhancer
type InferableComponentEnhancer<TInjectedProps> = InferableComponentEnhancerWithProps<TInjectedProps, {}>;
type InferableComponentEnhancerWithProps
type InferableComponentEnhancerWithProps<TInjectedProps, TNeedsProps> = < C extends JSXElementConstructor<Matching<TInjectedProps, GetProps<C>>>>( component: C) => ConnectedComponent< C, DistributiveOmit< GetLibraryManagedProps<C>, keyof Shared<TInjectedProps, GetLibraryManagedProps<C>> > & TNeedsProps>;
type InferThunkActionCreatorType
type InferThunkActionCreatorType<TActionCreator extends (...args: any[]) => any> = TActionCreator extends ( ...args: infer TParams ) => (...args: any[]) => infer TReturn ? (...args: TParams) => TReturn : TActionCreator;
type MapDispatchToProps
type MapDispatchToProps<TDispatchProps, TOwnProps> = | MapDispatchToPropsFunction<TDispatchProps, TOwnProps> | TDispatchProps;
type MapDispatchToPropsFactory
type MapDispatchToPropsFactory<TDispatchProps, TOwnProps> = ( dispatch: Dispatch<Action>, ownProps: TOwnProps) => MapDispatchToPropsFunction<TDispatchProps, TOwnProps>;
type MapDispatchToPropsFunction
type MapDispatchToPropsFunction<TDispatchProps, TOwnProps> = ( dispatch: Dispatch<Action>, ownProps: TOwnProps) => TDispatchProps;
type MapDispatchToPropsNonObject
type MapDispatchToPropsNonObject<TDispatchProps, TOwnProps> = | MapDispatchToPropsFactory<TDispatchProps, TOwnProps> | MapDispatchToPropsFunction<TDispatchProps, TOwnProps>;
type MapDispatchToPropsParam
type MapDispatchToPropsParam<TDispatchProps, TOwnProps> = | MapDispatchToPropsFactory<TDispatchProps, TOwnProps> | MapDispatchToProps<TDispatchProps, TOwnProps>;
type MapStateToProps
type MapStateToProps<TStateProps, TOwnProps, State = DefaultRootState> = ( state: State, ownProps: TOwnProps) => TStateProps;
type MapStateToPropsFactory
type MapStateToPropsFactory<TStateProps, TOwnProps, State = DefaultRootState> = ( initialState: State, ownProps: TOwnProps) => MapStateToProps<TStateProps, TOwnProps, State>;
type MapStateToPropsParam
type MapStateToPropsParam<TStateProps, TOwnProps, State = DefaultRootState> = | MapStateToPropsFactory<TStateProps, TOwnProps, State> | MapStateToProps<TStateProps, TOwnProps, State> | null | undefined;
type Matching
type Matching<InjectedProps, DecorationTargetProps> = { [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 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 MergeProps
type MergeProps<TStateProps, TDispatchProps, TOwnProps, TMergedProps> = ( stateProps: TStateProps, dispatchProps: TDispatchProps, ownProps: TOwnProps) => TMergedProps;
type Omit
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
type ResolveArrayThunks
type ResolveArrayThunks<TDispatchProps extends readonly any[]> = TDispatchProps extends [ infer A1, infer A2, infer A3, infer A4, infer A5, infer A6, infer A7, infer A8, infer A9 ] ? [ HandleThunkActionCreator<A1>, HandleThunkActionCreator<A2>, HandleThunkActionCreator<A3>, HandleThunkActionCreator<A4>, HandleThunkActionCreator<A5>, HandleThunkActionCreator<A6>, HandleThunkActionCreator<A7>, HandleThunkActionCreator<A8>, HandleThunkActionCreator<A9> ] : TDispatchProps extends [ infer A1, infer A2, infer A3, infer A4, infer A5, infer A6, infer A7, infer A8 ] ? [ HandleThunkActionCreator<A1>, HandleThunkActionCreator<A2>, HandleThunkActionCreator<A3>, HandleThunkActionCreator<A4>, HandleThunkActionCreator<A5>, HandleThunkActionCreator<A6>, HandleThunkActionCreator<A7>, HandleThunkActionCreator<A8> ] : TDispatchProps extends [ infer A1, infer A2, infer A3, infer A4, infer A5, infer A6, infer A7 ] ? [ HandleThunkActionCreator<A1>, HandleThunkActionCreator<A2>, HandleThunkActionCreator<A3>, HandleThunkActionCreator<A4>, HandleThunkActionCreator<A5>, HandleThunkActionCreator<A6>, HandleThunkActionCreator<A7> ] : TDispatchProps extends [ infer A1, infer A2, infer A3, infer A4, infer A5, infer A6 ] ? [ HandleThunkActionCreator<A1>, HandleThunkActionCreator<A2>, HandleThunkActionCreator<A3>, HandleThunkActionCreator<A4>, HandleThunkActionCreator<A5>, HandleThunkActionCreator<A6> ] : TDispatchProps extends [infer A1, infer A2, infer A3, infer A4, infer A5] ? [ HandleThunkActionCreator<A1>, HandleThunkActionCreator<A2>, HandleThunkActionCreator<A3>, HandleThunkActionCreator<A4>, HandleThunkActionCreator<A5> ] : TDispatchProps extends [infer A1, infer A2, infer A3, infer A4] ? [ HandleThunkActionCreator<A1>, HandleThunkActionCreator<A2>, HandleThunkActionCreator<A3>, HandleThunkActionCreator<A4> ] : TDispatchProps extends [infer A1, infer A2, infer A3] ? [ HandleThunkActionCreator<A1>, HandleThunkActionCreator<A2>, HandleThunkActionCreator<A3> ] : TDispatchProps extends [infer A1, infer A2] ? [HandleThunkActionCreator<A1>, HandleThunkActionCreator<A2>] : TDispatchProps extends [infer A1] ? [HandleThunkActionCreator<A1>] : TDispatchProps extends Array<infer A> ? Array<HandleThunkActionCreator<A>> : TDispatchProps extends ReadonlyArray<infer A> ? ReadonlyArray<HandleThunkActionCreator<A>> : never;
type ResolveThunks
type ResolveThunks<TDispatchProps> = TDispatchProps extends { [key: string]: any } ? { [C in keyof TDispatchProps]: HandleThunkActionCreator<TDispatchProps[C]>; } : TDispatchProps;
type RootStateOrAny
type RootStateOrAny = AnyIfEmpty<DefaultRootState>;
type Selector
type Selector<S, TProps, TOwnProps = null> = TOwnProps extends null | undefined ? (state: S) => TProps : (state: S, ownProps: TOwnProps) => TProps;
type SelectorFactory
type SelectorFactory<S, TProps, TOwnProps, TFactoryOptions> = ( dispatch: Dispatch<Action>, factoryOptions: TFactoryOptions) => Selector<S, TProps, TOwnProps>;
Initializes a selector function (during each instance's constructor). That selector function is called any time the connector component needs to compute new props, as a result of a store state change or receiving new props. The result of selector is expected to be a plain object, which is passed as the props to the wrapped component. If a consecutive call to selector returns the same object (===) as its previous call, the component will not be re-rendered. It's the responsibility of selector to return that previous object when appropriate.
type Shared
type Shared<InjectedProps, DecorationTargetProps> = { [P in Extract< keyof InjectedProps, keyof DecorationTargetProps >]?: InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : never;};
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.
Package Files (1)
Dependencies (4)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/react-redux
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/react-redux)
- HTML<a href="https://www.jsdocs.io/package/@types/react-redux"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3670 ms. - Missing or incorrect documentation? Open an issue for this package.