Files
react.dev/examples/16-3-release-blog-post/hoc-theme-example.js
2018-03-15 09:42:49 -07:00

11 lines
249 B
JavaScript

function withTheme(Component) {
return function ThemedComponent(props) {
// highlight-range{2-4}
return (
<ThemeContext.Consumer>
{theme => <Component {...props} theme={theme} />}
</ThemeContext.Consumer>
);
};
}