Created
July 25, 2018 10:35
-
-
Save karooolis/16dd46a515d0b20bfaf41eb5797b8b4b 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 from 'react'; | |
const withColor = BaseComponent => { | |
console.log(this); | |
class EnhancedComponent extends React.Component { | |
getRandomColor() { | |
var letters = '0123456789ABCDEF'; | |
var color = '#'; | |
for (let i = 0; i < 6; i++) { | |
color += letters[Math.floor(Math.random() * 16)]; | |
} | |
return color; | |
} | |
render() { | |
console.log(this); | |
return <BaseComponent color={this.getRandomColor()} {...this.props} />; | |
} | |
} | |
return EnhancedComponent; | |
}; | |
export default withColor; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment