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.

[Support] MakeStyles crashes with "Can't assign to property" error

See original GitHub issue

I’ve recently switched from @mui/styles to react-tss and I’m experiencing an error:

Uncaught TypeError: can't assign to property "label" on "ltr": not an object

Tracking the error down I’m lead to the makeStyles.js file, line ~45

  const cssObject = cssObjectByRuleName[ruleName];
  if (!cssObject.label) {
      cssObject.label = `${name !== undefined ? `${name}-` : ""}${ruleName}`;
  }

In this error case, the ruleName is direction resulting in a cssObject of the string ltr. Attempting to write to cssObject.label causes the error above.

I’ve checked my codebase and I’m not modifying the direction anywhere, so I don’t really understand why this is happening and could really use some assistance.

Thanks

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
thehigcommented, Jun 29, 2022

Yup that worked! Thanks, and sorry for the bother

1reaction
garronejcommented, Jun 29, 2022

Glad you figured it out.

This would be withTheme:

import { useStyles } from "tss-react/mui";

function withTheme(Component){

   function ComponentWithTheme(props){

        const { theme }= useStyles();
        
        return <Component {...props} theme={theme} />;

   }
   
   ComponentWithTheme.name = `${Component.name}WithTheme`;
   
   return ComponentWithTheme;

}
Read more comments on GitHub >

github_iconTop Results From Across the Web

makeStyles, withTheme and useTheme not working #14416
I'm getting an error: Uncaught TypeError: Cannot read property 'borderRadius' of undefined . Digging into it, I see that the theme object ...
Read more >
MUI - makeStyles - Cannot read properties of undefined
Despite this, my code appears to follow the changes that the documentations asks for. So what could be causing this error? app.js import...
Read more >
material-ui/core/CHANGELOG.md - UNPKG
The Tabs `fullWidth` and `scrollable` properties can't be used at the same time. The API change prevents any awkward usage. 22.
Read more >
@mui/styles | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
front-end/node_modules/@material-ui/styles/CHANGELOG.md
A way to get location (latitude and longitude), elevation, speed and other relevant data from individual satellites from the Starlink constellation.
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