Last active
February 26, 2019 07:47
-
-
Save michal-wrzosek/0a1d864805b5c13bbdc6a9a5ee14a641 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
const theme = { | |
fontColor: 'red', | |
}; | |
// HOC | |
const withTheme = (Component) => props => <Component {...props} theme={theme} />; | |
// Component | |
const List = ({ items, theme }) => ( | |
<ul style={{ color: theme.fontColor }}> | |
{items.map((item, index) => ( | |
<li key={index}>{item}</li> | |
))} | |
</ul> | |
); | |
// Wrapping Component in HOC | |
const ListWithTheme = withTheme(List); | |
const App = () => <ListWithTheme items={['one', 'two', 'three']} />; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment