Skip to content

Commit b7ef178

Browse files
committed
Rename DecoratedComponent => WrappedComponent, getUnderlyingRef() => getWrappedInstance()
1 parent 6178a0a commit b7ef178

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

Diff for: src/components/createConnect.js

+7-13
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ export default function createConnect(React) {
6666
return mergedProps;
6767
}
6868

69-
return function wrapWithConnect(DecoratedComponent) {
69+
return function wrapWithConnect(WrappedComponent) {
7070
class Connect extends Component {
71-
static displayName = `Connect(${getDisplayName(DecoratedComponent)})`;
72-
static DecoratedComponent = DecoratedComponent;
71+
static displayName = `Connect(${getDisplayName(WrappedComponent)})`;
72+
static WrappedComponent = WrappedComponent;
7373

7474
static contextTypes = {
7575
store: storeShape.isRequired
@@ -82,8 +82,6 @@ export default function createConnect(React) {
8282
constructor(props, context) {
8383
super(props, context);
8484
this.version = version;
85-
this.setUnderlyingRef = ::this.setUnderlyingRef;
86-
8785
this.stateProps = computeStateProps(context);
8886
this.dispatchProps = computeDispatchProps(context);
8987
this.state = this.computeNextState();
@@ -179,18 +177,14 @@ export default function createConnect(React) {
179177
}
180178
}
181179

182-
getUnderlyingRef() {
183-
return this.underlyingRef;
184-
}
185-
186-
setUnderlyingRef(instance) {
187-
this.underlyingRef = instance;
180+
getWrappedInstance() {
181+
return this.refs.wrappedInstance;
188182
}
189183

190184
render() {
191185
return (
192-
<DecoratedComponent ref={this.setUnderlyingRef}
193-
{...this.state} />
186+
<WrappedComponent ref='wrappedInstance'
187+
{...this.state} />
194188
);
195189
}
196190
}

Diff for: test/components/connect.spec.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ describe('React', () => {
285285
expect(div.props.stateThing).toBe('HELLO azbzcZ');
286286
});
287287

288-
it('should merge actionProps into DecoratedComponent', () => {
288+
it('should merge actionProps into WrappedComponent', () => {
289289
const store = createStore(() => ({
290290
foo: 'bar'
291291
}));
@@ -700,7 +700,7 @@ describe('React', () => {
700700
).displayName).toBe('Connect(Component)');
701701
});
702702

703-
it('should expose the wrapped component as DecoratedComponent', () => {
703+
it('should expose the wrapped component as WrappedComponent', () => {
704704
class Container extends Component {
705705
render() {
706706
return <div />;
@@ -710,7 +710,7 @@ describe('React', () => {
710710
const decorator = connect(state => state);
711711
const decorated = decorator(Container);
712712

713-
expect(decorated.DecoratedComponent).toBe(Container);
713+
expect(decorated.WrappedComponent).toBe(Container);
714714
});
715715

716716
it('should return the instance of the wrapped component for use in calling child methods', () => {
@@ -744,7 +744,8 @@ describe('React', () => {
744744
const decorated = TestUtils.findRenderedComponentWithType(tree, Decorated);
745745

746746
expect(() => decorated.someInstanceMethod()).toThrow();
747-
expect(decorated.getUnderlyingRef().someInstanceMethod()).toBe(someData);
747+
expect(decorated.getWrappedInstance().someInstanceMethod()).toBe(someData);
748+
expect(decorated.refs.wrappedInstance.someInstanceMethod()).toBe(someData);
748749
});
749750
});
750751
});

0 commit comments

Comments
 (0)