Rocket.Chat.ReactNative/app/theme.js

15 lines
410 B
JavaScript
Raw Normal View History

2019-12-04 16:39:53 +00:00
import React from 'react';
import hoistNonReactStatics from 'hoist-non-react-statics';
export const ThemeContext = React.createContext(null);
export function withTheme(Component) {
const ThemedComponent = props => (
<ThemeContext.Consumer>
{contexts => <Component {...props} {...contexts} />}
</ThemeContext.Consumer>
);
hoistNonReactStatics(ThemedComponent, Component);
return ThemedComponent;
}