mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
[react-redux] Add connectAdvanced from v5 (#18488)
This commit is contained in:
committed by
Mohamed Hegazy
parent
4b5aedb84c
commit
31996672cf
Vendored
+84
-4
@@ -1,6 +1,6 @@
|
||||
// Type definitions for react-redux 4.4.47
|
||||
// Project: https://github.com/rackt/react-redux
|
||||
// Definitions by: Qubo <https://github.com/tkqubo>, Sean Kelley <https://github.com/seansfkelley>, Thomas Hasner <https://github.com/thasner>
|
||||
// Type definitions for react-redux 5.0.5
|
||||
// Project: https://github.com/reactjs/react-redux
|
||||
// Definitions by: Qubo <https://github.com/tkqubo>, Sean Kelley <https://github.com/seansfkelley>, Thomas Hasner <https://github.com/thasner>, Kenzie Togami <https://github.com/kenzierocks>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -19,6 +19,10 @@ export interface DispatchProp<S> {
|
||||
dispatch: Dispatch<S>;
|
||||
}
|
||||
|
||||
interface AdvancedComponentDecorator<TProps, TOwnProps> {
|
||||
(component: Component<TProps>): ComponentClass<TOwnProps>;
|
||||
}
|
||||
|
||||
interface ComponentDecorator<TMergedProps, TOwnProps> {
|
||||
(component: Component<TOwnProps & TMergedProps>): ComponentClass<TOwnProps>;
|
||||
}
|
||||
@@ -149,7 +153,7 @@ interface MergeProps<TStateProps, TDispatchProps, TOwnProps, TMergedProps> {
|
||||
(stateProps: TStateProps, dispatchProps: TDispatchProps, ownProps: TOwnProps): TMergedProps;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
interface Options extends ConnectOptions {
|
||||
/**
|
||||
* If true, implements shouldComponentUpdate and shallowly compares the result of mergeProps,
|
||||
* preventing unnecessary updates, assuming that the component is a “pure” component
|
||||
@@ -165,6 +169,82 @@ interface Options {
|
||||
withRef?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects a React component to a Redux store. It is the base for {@link connect} but is less opinionated about
|
||||
* how to combine <code>state</code>, <code>props</code>, and <code>dispatch</code> 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 class for you to use.
|
||||
*
|
||||
* @param selectorFactory The selector factory. See {@type SelectorFactory} for details.
|
||||
* @param connectOptions If specified, further customizes the behavior of the connector. Additionally, any extra
|
||||
* options will be passed through to your <code>selectorFactory</code> in the <code>factoryOptions</code> argument.
|
||||
*/
|
||||
export declare function connectAdvanced<S, TProps, TOwnProps, TFactoryOptions = {}>(
|
||||
selectorFactory: SelectorFactory<S, TProps, TOwnProps, TFactoryOptions>,
|
||||
connectOptions?: ConnectOptions & TFactoryOptions
|
||||
): AdvancedComponentDecorator<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 <code>selector</code> is expected to be a plain object, which is passed as the props to the wrapped
|
||||
* component. If a consecutive call to <code>selector</code> returns the same object (<code>===</code>) as its previous
|
||||
* call, the component will not be re-rendered. It's the responsibility of <code>selector</code> to return that
|
||||
* previous object when appropriate.
|
||||
*/
|
||||
export interface SelectorFactory<S, TProps, TOwnProps, TFactoryOptions> {
|
||||
(dispatch: Dispatch<S>, factoryOptions: TFactoryOptions): Selector<S, TProps, TOwnProps>
|
||||
}
|
||||
|
||||
export interface Selector<S, TProps, TOwnProps> {
|
||||
(state: S, ownProps: TOwnProps): TProps
|
||||
}
|
||||
|
||||
export interface ConnectOptions {
|
||||
/**
|
||||
* Computes the connector component's displayName property relative to that of the wrapped component. Usually
|
||||
* overridden by wrapper functions.
|
||||
*
|
||||
* @default name => 'ConnectAdvanced('+name+')'
|
||||
* @param componentName
|
||||
*/
|
||||
getDisplayName?: (componentName: string) => string
|
||||
/**
|
||||
* Shown in error messages. Usually overridden by wrapper functions.
|
||||
*
|
||||
* @default 'connectAdvanced'
|
||||
*/
|
||||
methodName?: string
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @default undefined
|
||||
*/
|
||||
renderCountProp?: string
|
||||
/**
|
||||
* Controls whether the connector component subscribes to redux store state changes. If set to false, it will only
|
||||
* re-render on <code>componentWillReceiveProps</code>.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
shouldHandleStateChanges?: boolean
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @default 'store'
|
||||
*/
|
||||
storeKey?: string
|
||||
/**
|
||||
* If true, stores a ref to the wrapped component instance and makes it available via getWrappedInstance() method.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
withRef?: boolean
|
||||
}
|
||||
|
||||
export interface ProviderProps {
|
||||
/**
|
||||
* The single Redux store in your application.
|
||||
|
||||
Reference in New Issue
Block a user