cssinjs / jss

JSS is an authoring tool for CSS which uses JavaScript as a host language.
https://cssinjs.org
MIT License
7.08k stars 400 forks source link

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

Open jonathan-l-rivera opened 3 years ago

jonathan-l-rivera commented 3 years ago

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):

jonathan-l-rivera commented 3 years ago

In the Codesandbox all dynamically passed media queries fail. But locally (although using the same versions of everything) only the first instance of a components works, while every other one fails. Weird behavior.