cssinjs / cssinjs/jss

Media-queries are not created for the classes declared as functions

Open
#1,557 2 comments 4 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.1k
Forks
386
PR merge metrics
No merged PRs in 30d

Description

__Expected behavior:__

When there is a class declared as a function, the media queries related to this class are applied. Hence, here a block with the exampleClass applied should be red on the screens wider than 600px.

```
exampleClass: (props) => ({
color: "white",
backgroundColor: "blue",
width: props.prop1 ? "50%" : "100%",

"@media(min-width:600px)": {
backgroundColor: "red"
}
})
```

__Describe the bug:__
For the classes declared as functions media queries are not applied unless they are declared as functions themselves.

Screenshot 2021-09-22 at 16 32 34

This variant won't work as well.

`
"@media(min-width:600px)": {
exampleClass: {
backgroundColor: "red"
}
}
`

But this one will do.

`
"@media(min-width:600px)": {
exampleClass: () => ({
backgroundColor: "red"
})
}
`

Screenshot 2021-09-22 at 16 35 07

__Reproduction:__

You may check the working reproduction example here - https://codesandbox.io/s/react-jss-bug-report-guijv

__Versions (please complete the following information):__
- jss: 10.7.1
- Browser: Chrome - Version 93.0.4577.82 (Official Build) (x86_64)
- OS: macOS 11.2.3 (20D91)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.