cssinjs / cssinjs/jss

React JSS media queries fail to work when passed as an object

Open
#1,434 1 comment 1 reaction 0 assignees View on GitHub
bug feature request
Dominant language
JavaScript
Stars
7.1k
Forks
386
PR merge metrics
No merged PRs in 30d

Description

__Expected behavior:__
I should be able to pass an object of media queries.

Example.
```
const useStyles = createUseStyles({
Button: ({queries }) => ({queries }),
});

// From component
const queries = {
'@media (min-width: 50px)': {
color: 'blue',
},
};

useStyles({queries});
```
Is this a supported use case? Or do media queries need to be hardcoded?

__Describe the bug:__
Media queries fail to work when passed dynamically.

__Codesandbox link:__
https://codesandbox.io/s/fragrant-tree-i4nfw?file=/src/App.js

__Versions (please complete the following information):__
- react-jss: 10.5.0
- react: 17.0.1
- react-dom: 17.0.1
- Browser Safari, Chrome, Firefox:
- OS MacOS 10.15.3:

Contributor guide

Open the contributing guide

Research direction

Start with the Codesandbox reproduction in src/App.js and verify the reported behavior using the supplied react-jss 10.5.0, React 17.0.1, and browser details. Trace how the dynamically passed media-query object is handled; done means the example works as expected or the supported usage is clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.