Last active
January 29, 2017 03:13
-
-
Save komkanit/962c34cfda28e5bebe9124b76d303221 to your computer and use it in GitHub Desktop.
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
| const CalculateWrapper = (WrappedComponent, operation) => (props) => ( | |
| <div> | |
| <div>{props.x + operation + props.y}</div> | |
| <WrappedComponent {...props} /> | |
| </div> | |
| ) | |
| const Increment = (props) => ( <h1>{props.x + props.y}</h1> ) | |
| const Decrease = (props) => ( <h1>{props.x - props.y}</h1> ) | |
| class App extends Component { | |
| render() { | |
| const CalculateIncrement = CalculateWrapper(Increment, '+') | |
| const CalculateDecrease = CalculateWrapper(Decrease, '-') | |
| return ( | |
| <div className="App"> | |
| <CalculateIncrement x={10} y={20} /> | |
| <CalculateDecrease x={10} y={20} /> | |
| </div> | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment