I've been trying to create a React HOC that will apply the corresponding styles to any component pass to it.
My idea was to do something similar to this
// Button.css.js const styles = {backgroundColor:"blue"} // Button.js const Button = (props) => <button {...props}/> // applyStyles.js const applyStyles = (Component) => (props) => { const styles = import style from `${Component.name}.css` return <Component {...props} style={styles} /> } I know applyStyles contains invalid syntax but is just to illustrate what is what I'm trying to do.
If any of you have a way around this I will really appreciate it.