Last active
February 22, 2018 11:57
-
-
Save cecigarcia/a874fbabaf1bf12cbb78ad8777370f89 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"; | |
class CustomComponent extends Component { | |
apiMethod() { /* ... */ } | |
}; | |
const StyledCustomComponent = props => ( | |
<CustomComponent {...props} style={{ padding: 10 }} /> | |
); | |
const EnhancedCustomComponent = props => ( | |
<StyledCustomComponent {...props} extraInfo={info} /> | |
); | |
class ParentComponent extends Component { | |
handleClick = () => this.component.apiMethod(); | |
render() { | |
return ( | |
<div> | |
<button onClick={this.handleClick}>call api method!</button> | |
<EnhancedCustomComponent ref={r => this.component = r } /> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment