Skip to content

Commit 482ab48

Browse files
committed
Merge pull request reduxjs#109 from bradgignac/decorated-component
Expose DecoratedComponent as static property.
2 parents a32604b + 464f30d commit 482ab48

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

src/components/createConnectDecorator.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export default function createConnectDecorator(React, Connector) {
77
return function connect(select) {
88
return DecoratedComponent => class ConnectorDecorator extends Component {
99
static displayName = `Connector(${getDisplayName(DecoratedComponent)})`;
10+
static DecoratedComponent = DecoratedComponent;
1011

1112
shouldComponentUpdate(nextProps) {
1213
return !shallowEqualScalar(this.props, nextProps);

src/components/createProvideDecorator.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export default function createProvideDecorator(React, Provider) {
66
return function provide(redux) {
77
return DecoratedComponent => class ProviderDecorator extends Component {
88
static displayName = `Provider(${getDisplayName(DecoratedComponent)})`;
9+
static DecoratedComponent = DecoratedComponent;
910

1011
render() {
1112
return (

test/components/connect.spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,18 @@ describe('React', () => {
5757

5858
expect(Container.displayName).toBe('Connector(Container)');
5959
});
60+
61+
it('sets DecoratedComponent to wrapped component', () => {
62+
class Container extends Component {
63+
render() {
64+
return <div />;
65+
}
66+
}
67+
68+
let decorator = connect(state => state);
69+
let ConnectorDecorator = decorator(Container);
70+
71+
expect(ConnectorDecorator.DecoratedComponent).toBe(Container);
72+
});
6073
});
6174
});

test/components/provide.spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,18 @@ describe('React', () => {
4848

4949
expect(Container.displayName).toBe('Provider(Container)');
5050
});
51+
52+
it('sets DecoratedComponent to wrapped component', () => {
53+
class Container extends Component {
54+
render() {
55+
return <div />;
56+
}
57+
}
58+
59+
let decorator = provide(state => state);
60+
let ProviderDecorator = decorator(Container);
61+
62+
expect(ProviderDecorator.DecoratedComponent).toBe(Container);
63+
});
5164
});
5265
});

0 commit comments

Comments
 (0)