Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

66
Views
React issue applying styles when converting existing component from class-based to function-based

I am having issues seeing styles getting applied from my component when converting my component from class-based to function-based component.

it is probably related to HOC issue.

So in my component, I have the styles defined as below;

const styles = ({palette: {somekit}}) => ({
    tabs: {
        backgroundColor: somekit.grey
    },
})

Earlier, it was a class-based component as below (and I could see the styles getting picked from above)

class MyHeader extends React.Component{}

However, after converting it into a function-based component as below, the styles defined above do not seem to be getting picked up.

function MyHeader(props) {}

In both the cases, I had the export defined as below;

export default withRouter(withStyles(styles, {name: 'MyStyle'})(MyHeader));

I suspect some issue with the way the component is exported above when converting from class-based to function-based. Does this export seem proper when using function-based component ?

---Updated--- This is how withStyles is defined;

import { withStyles as withStylesWODefault } from '@material-ui/styles';

    import defTheme from './defTheme';
    
    export default function withStyles(styles, options) {
      return withStylesWODefault(styles, {
        defTheme,
        ...options
      });
    }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!