Created
December 22, 2015 21:53
-
-
Save d6u/830767507ef014f4f4d2 to your computer and use it in GitHub Desktop.
Apply className with Higher Order Component
This file contains hidden or 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 { Component } from 'React'; | |
| class MyComponent extends Component { | |
| render() { | |
| return ( | |
| <div className='container'><div className='box'>the box</div></div> | |
| ); | |
| } | |
| } | |
| export var Enhance = ComposedComponent => class extends Component { | |
| render() { | |
| // How can I apply 'some_class_name' to .container in ComposedComponent | |
| // without ComposedComponent knowing what to do? | |
| return <ComposedComponent className='some_class_name' />; | |
| } | |
| }; | |
| const NewComponent = Enhance(MyComponent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment