Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forward ref to the wrapped component #266

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 13 additions & 4 deletions packages/react-meteor-data/ReactMeteorData.jsx
Expand Up @@ -175,14 +175,23 @@ export default function connect(options) {
const { getMeteorData, pure = true } = expandedOptions;

const BaseComponent = pure ? ReactPureComponent : ReactComponent;
return (WrappedComponent) => (

return (WrappedComponent) => {
class ReactMeteorDataComponent extends BaseComponent {
getMeteorData() {
return getMeteorData(this.props);
const { forwardedRef, ...props } = this.props;

return getMeteorData(props);
}

render() {
return <WrappedComponent {...this.props} {...this.data} />;
const { forwardedRef, ...props } = this.props;
return <WrappedComponent ref={forwardedRef} {...props} {...this.data} />;
}
}
);

return React.forwardRef((props, ref) => (
<ReactMeteorDataComponent {...props} forwardedRef={ref} />
));
};
}