Connects a React component to a Redux store. It is the base for
connect() but is less opinionated about how to combine
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 class for you to use.
Most applications will not need to use this, as the default behavior in
connect is intended to work for most use cases.
connectAdvancedwas added in version 5.0, and
connectwas reimplemented as a specific set of parameters to
selectorFactory(dispatch, factoryOptions): selector(state, ownProps): props(Function): 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
selectoris expected to be a plain object, which is passed as the props to the wrapped component. If a consecutive call to
selectorreturns the same object (
===) as its previous call, the component will not be re-rendered. It's the responsibility of
selectorto return that previous object when appropriate.
connectOptions] (Object) If specified, further customizes the behavior of the connector.
getDisplayName] (Function): computes the connector component's displayName property relative to that of the wrapped component. Usually overridden by wrapper functions. Default value:
name => 'ConnectAdvanced('+name+')'
methodName] (String): shown in error messages. Usually overridden by wrapper functions. Default value:
renderCountProp] (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 value:
shouldHandleStateChanges] (Boolean): controls whether the connector component subscribes to redux store state changes. If set to false, it will only re-render when parent component re-renders. Default value:
forwardRef] (Boolean): If true, adding a ref to the connected wrapper component will actually return the instance of the wrapped component.
Additionally, any extra options passed via
connectOptionswill be passed through to your
A higher-order React component class that builds props from the store state and passes them to the wrapped component. A higher-order component is a function which accepts a component argument and returns a new component.
WrappedComponent(Component): The original component class passed to
All the original static methods of the component are hoisted.
connectAdvancedreturns a higher-order component, it needs to be invoked two times. The first time with its arguments as described above, and a second time, with the component:
connectAdvanceddoes not modify the passed React component. It returns a new, connected component, that you should use instead.