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

Warning: [JSS] Function values inside function rules are not supported. #1474

Open amerllica opened 3 years ago

amerllica commented 3 years ago

Expected behavior: Do not show warning, because it works well.

Describe the bug: For some reasons I wrote my code like this:

const useStyles = createUseStyles(({ colors, variables, breakpoints }) => ({
  // above line get the theme variables
  cropperRoot: {
    margin: [0, -variables.gutter],
  },
  cropContainer: ({ cropWrapSize = 250 }) => ({
    // above line get the variables from passed props to useState({ cropWrapSize })
    height: cropWrapSize + 44 + 60,
    padding: [44, 0, 60],
    overflow: 'hidden',
    background: colors.backgroundIcon,
  }),

Now I'm faced to this warning:

Warning: [JSS] Function values inside function rules are not supported.

Versions (please complete the following information):

Why this Warning is shown?

kof commented 3 years ago

that warning should be only shown when function value used inside a function rule like this:

createUseStyles({
   a: () => ({
     color: () => 'red'
   })
})

This should be a bug.

amerllica commented 3 years ago

@kof , But even in the below case I got that warning:

createUseStyles(({ colors }) => ({
   a: ({ isDisabled }) => ({
     color: isDisabled ? colors.gray : colors.primary,
   }),
}));

See, it is a function inside function too. I migrate from JSS to @material-ui/styles, I know it is a wrapper for JSS and ReactJSS but issues were settled inside itself.

kof commented 3 years ago

Like I said this should be a bug.