Created
July 25, 2018 05:24
-
-
Save karooolis/b4647841c99ee99120fb533bfb050abe 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 => { | |
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() { | |
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