diff --git a/src/components/createConnectDecorator.js b/src/components/createConnectDecorator.js
index db56935a3..4349d4fc3 100644
--- a/src/components/createConnectDecorator.js
+++ b/src/components/createConnectDecorator.js
@@ -114,8 +114,12 @@ export default function createConnectDecorator(React) {
return merged;
}
+ getUnderlyingRef() {
+ return this.underlyingRef;
+ }
+
render() {
- return ;
+ return (this.underlyingRef = component)} {...this.merge()} />;
}
};
};
diff --git a/test/components/connect.spec.js b/test/components/connect.spec.js
index 5938d99c3..d8e35026b 100644
--- a/test/components/connect.spec.js
+++ b/test/components/connect.spec.js
@@ -514,5 +514,39 @@ describe('React', () => {
expect(decorated.DecoratedComponent).toBe(Container);
});
+
+ it('should return the instance of the wrapped component for use in calling child methods', () => {
+ const store = createStore(() => ({}));
+
+ const someData = {
+ some: 'data'
+ };
+
+ class Container extends Component {
+ someInstanceMethod() {
+ return someData;
+ }
+
+ render() {
+ return ;
+ }
+ }
+
+ const decorator = connect(state => state);
+ const Decorated = decorator(Container);
+
+ const tree = TestUtils.renderIntoDocument(
+
+ {() => (
+
+ )}
+
+ );
+
+ const decorated = TestUtils.findRenderedComponentWithType(tree, Decorated);
+
+ expect(() => decorated.someInstanceMethod()).toThrow();
+ expect(decorated.getUnderlyingRef().someInstanceMethod()).toBe(someData);
+ });
});
});