Skip to content

Commit 7be6420

Browse files
committed
Add name option to connect()
1 parent 253ce8b commit 7be6420

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

docs/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Instead, it *returns* a new, connected component class, for you to use.
7171
* [`options`] *(Object)* If specified, further customizes the behavior of the connector.
7272
* [`pure = true`] *(Boolean)*: 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`.*
7373
* [`withRef = false`] *(Boolean)*: If true, stores a ref to the wrapped component instance and makes it available via `getWrappedInstance()` method. *Defaults to `false`.*
74+
* [`name = "Connect"`] *(String)*: Custom display name for the generated wrapper component. This can been seen in the React Devtools and in warning messages. *Defaults to `Connect`.*
7475

7576
#### Returns
7677

src/components/connect.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
4646
}
4747

4848
const finalMergeProps = mergeProps || defaultMergeProps
49-
const { pure = true, withRef = false } = options
49+
const { pure = true, withRef = false, name = "Connect" } = options
5050
const checkMergedEquals = pure && finalMergeProps !== defaultMergeProps
5151

5252
// Helps track hot reloading.
5353
const version = nextVersion++
5454

5555
return function wrapWithConnect(WrappedComponent) {
56-
const connectDisplayName = `Connect(${getDisplayName(WrappedComponent)})`
56+
const connectDisplayName = `${name}(${getDisplayName(WrappedComponent)})`
5757

5858
function checkStateShape(props, methodName) {
5959
if (!isPlainObject(props)) {

0 commit comments

Comments
 (0)