question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

react-jss 10.7.0 broke useStyle()

See original GitHub issue

Expected behavior: Use useStyle without arguments. It works in <=10.6.0.

Describe the bug: I updated to 10.7.0 and found the following error. Cannot read property 'theme' of undefined.

It looks like an error was reported here 👇 https://github.com/cssinjs/jss/blob/v10.7.0/packages/react-jss/src/createUseStyles.js#L43

I updated to 10.7.0 and found that previously normal code was reporting the following error, which appears to be reported here.

Reproduction:

const useLabelStyles = createUseStyles({
  label: {
    color: "red"
  }
});
const Label = ({ children }) => {
  const classes = useLabelStyles(); // <=== Here
  return <label className={classes.button}>{children}</label>;
};

I copied the example code from the official website and reproduced the problem on CodeSandbox. https://codesandbox.io/s/react-jss-1070-broke-usestyle-zv6lg

Versions (please complete the following information):

  • react-jss: 10.7.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
kofcommented, Jun 28, 2021
3reactions
imemircommented, Jun 28, 2021

I have this problem too @kof

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introducing Hooks - React
Hooks don't contain any breaking changes. Available now. Hooks are now available with the release of v16.8.0. There are no plans to remove...
Read more >
React with MUI's useStyles() giving me a hooks rules violation
The app returns no errors on npm start , but the page itself gives me the invalid hook call pointing to the line...
Read more >
Bug: React 18 types broken since the type release a ... - GitHub
A few hours ago, a major version of React types for Typescript was released. I have tried to test this right away to...
Read more >
Troubleshooting - Material UI - MUI
There are two reasons why component styles may be broken after you've completed all steps in the migration process. First, check if you...
Read more >
How To Style React Components | DigitalOcean
Writing style strings manually is difficult to do and can introduce bugs. A missing color or semicolon will break the entire string. Fortunately ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found