Skip to content

Commit

Permalink
feat(connect.js): expose get wrapped instance
Browse files Browse the repository at this point in the history
So that it can be used the same
as react-redux's connect
  • Loading branch information
adrienharnay authored Feb 13, 2018
1 parent fa3a9b4 commit e9cac70
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,24 @@ export default (...args) => (WrappedComponent) => {
);
};

getWrappedInstance = () =>
this.innerRef ? this.innerRef.getWrappedInstance() : null;

render() {
const { ConnectedComponent } = this;
const passedProps = {
...this.props,
...this.state,
};

return <ConnectedComponent {...passedProps} />;
return (
<ConnectedComponent
ref={(ref) => {
this.innerRef = ref;
}}
{...passedProps}
/>
);
}
}

Expand Down

0 comments on commit e9cac70

Please sign in to comment.