Skip to content

Instantly share code, notes, and snippets.

@datvtwkm
Last active August 26, 2018 05:25
Show Gist options
  • Save datvtwkm/eb062ffe4fe41e0165f9f6b5a1b6bba8 to your computer and use it in GitHub Desktop.
Save datvtwkm/eb062ffe4fe41e0165f9f6b5a1b6bba8 to your computer and use it in GitHub Desktop.
// @flow
import React, { Component } from 'react';
import type { ComponentType } from 'react';
export default WrappedComponent=> (
class EnhancedComponent extends Component<any> {
wrappedInstance: ?ComponentType<any> = null;
setWrappedInstance = (c: any) => { this.wrappedInstance = c; };
render(){
return (<WrappedComponent ref={this.setWrappedInstance} {...this.props}/>)
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment