Last active
August 8, 2016 13:00
-
-
Save thekevinscott/795f169a7de50c7a5151cb847113d2d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { connect } from 'react-redux'; | |
function getWrappedComponent( | |
component, | |
[ | |
mapStateToProps, | |
mapDispatchToProps, | |
mergeProps, | |
options, | |
], | |
) { | |
return connect( | |
mapStateToProps, | |
mapDispatchToProps, | |
mergeProps, | |
{ | |
...options, | |
withRef: true, | |
}, | |
)(component); | |
} | |
const patchedConnect = (...args) => component => { | |
const WrappedComponent = getWrappedComponent(component, args); | |
class WrapperComponent extends Component { | |
render() { | |
return ( | |
<WrappedComponent | |
{...this.props} | |
ref={c => { console.log(c); }} | |
/> | |
); | |
} | |
} | |
return WrapperComponent; | |
}; | |
export default patchedConnect; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment