Skip to content

Commit 0949488

Browse files
committed
Move stuff around, finish removing provide() and <Connector>
1 parent 4a5756e commit 0949488

File tree

9 files changed

+34
-130
lines changed

9 files changed

+34
-130
lines changed

src/components/createAll.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
import createProvider from './createProvider';
2-
import createProvideDecorator from './createProvideDecorator';
3-
4-
import createConnectDecorator from './createConnectDecorator';
2+
import createConnect from './createConnect';
53

64
export default function createAll(React) {
7-
// Wrapper components
85
const Provider = createProvider(React);
6+
const connect = createConnect(React);
97

10-
// Higher-order components (decorators)
11-
const provide = createProvideDecorator(React, Provider);
12-
const connect = createConnectDecorator(React);
13-
14-
return { Provider, provide, connect };
8+
return { Provider, connect };
159
}
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import createStoreShape from '../utils/createStoreShape';
2-
import getDisplayName from '../utils/getDisplayName';
32
import shallowEqualScalar from '../utils/shallowEqualScalar';
43
import shallowEqual from '../utils/shallowEqual';
54
import isPlainObject from '../utils/isPlainObject';
@@ -12,8 +11,11 @@ const emptyBinder = () => ({});
1211

1312
const identityMerge = (slice, actionsCreators, props) => ({ ...props, ...slice, ...actionsCreators});
1413

14+
function getDisplayName(Component) {
15+
return Component.displayName || Component.name || 'Component';
16+
}
1517

16-
export default function createConnectDecorator(React) {
18+
export default function createConnect(React) {
1719
const { Component, PropTypes } = React;
1820
const storeShape = createStoreShape(PropTypes);
1921

@@ -25,7 +27,7 @@ export default function createConnectDecorator(React) {
2527
const merge = mergeHandler;
2628

2729
return DecoratedComponent => class ConnectDecorator extends Component {
28-
static displayName = `ConnectDecorator(${getDisplayName(DecoratedComponent)})`;
30+
static displayName = `Connect(${getDisplayName(DecoratedComponent)})`;
2931
static DecoratedComponent = DecoratedComponent;
3032

3133
static contextTypes = {

src/components/createProvideDecorator.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import React from 'react';
22
import createAll from './components/createAll';
33

4-
export const { Provider, Connector, provide, connect, connectDeprecated } = createAll(React);
4+
export const { Provider, connect } = createAll(React);

src/native.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import React from 'react-native';
22
import createAll from './components/createAll';
33

4-
export const { Provider, Connector, provide, connect, connectDeprecated } = createAll(React);
4+
export const { Provider, connect } = createAll(React);

src/utils/getDisplayName.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/components/connect.spec.js

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import expect from 'expect';
22
import jsdomReact from './jsdomReact';
3-
import React, { PropTypes, Component } from 'react/addons';
4-
import { createStore, combineReducers } from 'redux';
3+
import React, { createClass, PropTypes, Component } from 'react/addons';
4+
import { createStore } from 'redux';
55
import { connect } from '../../src/index';
66

77
const { TestUtils } = React.addons;
@@ -433,14 +433,30 @@ describe('React', () => {
433433
});
434434

435435
it('should set the displayName correctly', () => {
436-
@connect(state => state)
437-
class Container extends Component {
438-
render() {
439-
return <div />;
436+
expect(connect(state => state)(
437+
class Foo extends Component {
438+
render() {
439+
return <div />;
440+
}
440441
}
441-
}
442+
).displayName).toBe('Connect(Foo)');
442443

443-
expect(Container.displayName).toBe('ConnectDecorator(Container)');
444+
expect(connect(state => state)(
445+
createClass({
446+
displayName: 'Bar',
447+
render() {
448+
return <div />;
449+
}
450+
})
451+
).displayName).toBe('Connect(Bar)');
452+
453+
expect(connect(state => state)(
454+
createClass({
455+
render() {
456+
return <div />;
457+
}
458+
})
459+
).displayName).toBe('Connect(Component)');
444460
});
445461

446462
it('should expose the wrapped component as DecoratedComponent', () => {

test/components/provide.spec.js

Lines changed: 0 additions & 68 deletions
This file was deleted.

test/utils/getDisplayName.spec.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)