How to use React Context value from a separate JSS styles component?

257 Views Asked by At

I have moved my react jss styles to another file. Now I am using React context to toggle thememode. And I want to change the styles when thememode toggles from true to false and vice versa.

But since my component styles are on a new file, I can't access useContext from there. It says cannot use useContext outside of a React function. So I can't change styles and colors when thememode is changed.

Is there any way that I can get the thememode or access the value of my context?

what I have tried:

I tried putting thememode as a prop in withStyles(styles(thememode))(Mycomponent), but I can't even access thememode constant outside of the function to which I have grabbed the thememode value using usecontext.

0

There are 0 best solutions below