Created
July 15, 2020 16:32
-
-
Save yuzhakovvv/aa562cd992880638f119d45b101e88c5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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'; | |
import PropTypes from 'prop-types'; | |
import { MuiThemeProvider } from '@material-ui/core/styles'; | |
import { lightTheme } from '~/config/theme/index'; | |
function getDisplayName(Component) { | |
return Component.displayName || Component.name || 'Component'; | |
} | |
export default function withLightTheme(Component) { | |
function LightThemeComponent(props) { | |
const { forwardedRef, ...rest } = props; | |
return ( | |
<MuiThemeProvider theme={lightTheme}> | |
<Component {...rest} ref={forwardedRef} /> | |
</MuiThemeProvider> | |
); | |
} | |
LightThemeComponent.propTypes = { | |
forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), | |
}; | |
LightThemeComponent.defaultProps = { | |
forwardedRef: undefined, | |
}; | |
LightThemeComponent.dislpayName = `LightTheme(${getDisplayName(Component)})`; | |
return React.forwardRef((props, ref) => ( | |
<LightThemeComponent {...props} forwardedRef={ref} /> | |
)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment