Material-ui: Passing props to makeStyles gives error: TypeError: Cannot read property 'rules' of undefined

Created on 7 Feb 2020  路  2Comments  路  Source: mui-org/material-ui

I have a dead simple component which I try to pass color to dynamically:

const useStyles = makeStyles({
  outlined: {
    marginBottom: 4,
    color: color => color
  }
})

function Label({ name, color }) {
  const classes = useStyles(color)

  return (
    <Chip
      className={classes.outlined}
      label={name}
      variant='outlined'
    />
  )
}

And when I add color: color => color I get the error:

TypeError: Cannot read property 'rules' of undefined
RuleList.updateOne
node_modules/jss/dist/jss.esm.js:956

Most helpful comment

We only support objects as the argument for the created hook

-const classes = useStyles(color)
+const classes = useStyles({color})


-color: color => color
+color: ({color}) => color

All 2 comments

Please provide a full reproduction test case. This would help a lot 馃懛 .
A live example would be perfect. This codesandbox.io template _may_ be a good starting point. Thank you!

We only support objects as the argument for the created hook

-const classes = useStyles(color)
+const classes = useStyles({color})


-color: color => color
+color: ({color}) => color
Was this page helpful?
0 / 5 - 0 ratings

Related issues

activatedgeek picture activatedgeek  路  3Comments

ericraffin picture ericraffin  路  3Comments

finaiized picture finaiized  路  3Comments

sys13 picture sys13  路  3Comments

mattmiddlesworth picture mattmiddlesworth  路  3Comments