Skip to content

Commit

Permalink
Add name option to connect()
Browse files Browse the repository at this point in the history
  • Loading branch information
esamattis committed May 28, 2016
1 parent 253ce8b commit 6075343
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Instead, it *returns* a new, connected component class, for you to use.
* [`options`] *(Object)* If specified, further customizes the behavior of the connector.
* [`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`.*
* [`withRef = false`] *(Boolean)*: If true, stores a ref to the wrapped component instance and makes it available via `getWrappedInstance()` method. *Defaults to `false`.*
* [`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'`.*

#### Returns

Expand Down
4 changes: 2 additions & 2 deletions src/components/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
}

const finalMergeProps = mergeProps || defaultMergeProps
const { pure = true, withRef = false } = options
const { pure = true, withRef = false, name = 'Connect' } = options
const checkMergedEquals = pure && finalMergeProps !== defaultMergeProps

// Helps track hot reloading.
const version = nextVersion++

return function wrapWithConnect(WrappedComponent) {
const connectDisplayName = `Connect(${getDisplayName(WrappedComponent)})`
const connectDisplayName = `${name}(${getDisplayName(WrappedComponent)})`

function checkStateShape(props, methodName) {
if (!isPlainObject(props)) {
Expand Down

0 comments on commit 6075343

Please sign in to comment.