Skip to content

Commit 6c504b9

Browse files
committed
fix length comparisons on xxxToProps functions
Testing finalMap{State|Dispatch}ToProps.length > 1 breaks when these functions are wrapped in generic decorator functions. Instead, test for !== 1.
1 parent 8a096db commit 6c504b9

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/components/connect.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
2828
wrapActionCreators(mapDispatchToProps) :
2929
mapDispatchToProps || defaultMapDispatchToProps
3030
const finalMergeProps = mergeProps || defaultMergeProps
31-
const shouldUpdateStateProps = finalMapStateToProps.length > 1
32-
const shouldUpdateDispatchProps = finalMapDispatchToProps.length > 1
31+
const shouldUpdateStateProps = finalMapStateToProps.length !== 1
32+
const shouldUpdateDispatchProps = finalMapDispatchToProps.length !== 1
3333
const { pure = true, withRef = false } = options
3434

3535
// Helps track hot reloading.

test/components/connect.spec.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,12 @@ describe('React', () => {
426426

427427
let invocationCount = 0
428428

429-
@connect(() => {
429+
/*eslint-disable no-unused-vars */
430+
@connect((arg1) => {
430431
invocationCount++
431432
return {}
432433
})
434+
/*eslint-enable no-unused-vars */
433435
class WithoutProps extends Component {
434436
render() {
435437
return <Passthrough {...this.props}/>
@@ -524,10 +526,12 @@ describe('React', () => {
524526

525527
let invocationCount = 0
526528

527-
@connect(null, () => {
529+
/*eslint-disable no-unused-vars */
530+
@connect(null, (arg1) => {
528531
invocationCount++
529532
return {}
530533
})
534+
/*eslint-enable no-unused-vars */
531535
class WithoutProps extends Component {
532536
render() {
533537
return <Passthrough {...this.props}/>

0 commit comments

Comments
 (0)