You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
15
15
16
-
It does not modify the component class passed to it; instead, it *returns* a new, connected component class for you to use.
16
+
It does not modify the component class passed to it; instead, it _returns_ a new, connected component class for you to use.
17
17
18
18
Most applications will not need to use this, as the default behavior in `connect` is intended to work for most use cases.
19
19
20
-
> Note: `connectAdvanced` was added in version 5.0, and `connect` was reimplemented as a specific set of parameters to `connectAdvanced`.
20
+
> Note: `connectAdvanced` was added in version 5.0, and `connect` was reimplemented as a specific set of parameters to `connectAdvanced`.
21
21
22
22
## Arguments
23
23
24
-
*`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 `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.
24
+
-`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 `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.
25
25
26
-
* [`connectOptions`] *(Object)* If specified, further customizes the behavior of the connector.
26
+
- [`connectOptions`] _(Object)_ If specified, further customizes the behavior of the connector.
27
27
28
-
* [`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+')'`
28
+
- [`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+')'`
29
29
30
-
* [`methodName`] *(String)*: shown in error messages. Usually overridden by wrapper functions. Default value: `'connectAdvanced'`
30
+
- [`methodName`] _(String)_: shown in error messages. Usually overridden by wrapper functions. Default value: `'connectAdvanced'`
31
31
32
-
* [`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: `undefined`
32
+
- [`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: `undefined`
33
33
34
-
* [`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:`true`
34
+
- [`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: `true`
35
35
36
-
* [`forwardRef`] *(Boolean)*: If true, adding a ref to the connected wrapper component will actually return the instance of the wrapped component.
36
+
- [`forwardRef`] _(Boolean)_: If true, adding a ref to the connected wrapper component will actually return the instance of the wrapped component.
37
37
38
-
* Additionally, any extra options passed via `connectOptions` will be passed through to your `selectorFactory` in the `factoryOptions` argument.
38
+
- Additionally, any extra options passed via `connectOptions` will be passed through to your `selectorFactory` in the `factoryOptions` argument.
39
39
40
40
<a id="connectAdvanced-returns"></a>
41
41
@@ -45,21 +45,20 @@ A higher-order React component class that builds props from the store state and
45
45
46
46
### Static Properties
47
47
48
-
*`WrappedComponent`*(Component)*: The original component class passed to `connectAdvanced(...)(Component)`.
48
+
-`WrappedComponent`_(Component)_: The original component class passed to `connectAdvanced(...)(Component)`.
49
49
50
50
### Static Methods
51
51
52
52
All the original static methods of the component are hoisted.
53
53
54
-
55
-
56
54
## Remarks
57
55
58
-
* Since `connectAdvanced` returns 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: `connectAdvanced(selectorFactory)(MyComponent)`.
56
+
- Since `connectAdvanced` returns 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: `connectAdvanced(selectorFactory)(MyComponent)`.
59
57
60
-
*`connectAdvanced` does not modify the passed React component. It returns a new, connected component, that you should use instead.
58
+
-`connectAdvanced` does not modify the passed React component. It returns a new, connected component, that you should use instead.
61
59
62
60
<a id="connectAdvanced-examples"></a>
61
+
63
62
### Examples
64
63
65
64
### Inject `todos` of a specific user depending on props, and inject `props.userId` into the action
@@ -71,10 +70,10 @@ import { bindActionCreators } from 'redux'
0 commit comments