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.

makeStyles always requires props

See original GitHub issue

makeStyles which does not use props should not require props

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

const useStyles = makeStyles({
  root: {
    backgroundColor: "white"
  }
});

export default function Home() {
  const classes = useStyles();
  return <div className={classes.root} />;
}

Expected 1 arguments, but got 0. An argument for 'props' was not provided for the useStyles class.

Expected Behavior 🤔

makeStyles which does not use props should not require props

Steps to Reproduce 🕹

https://codesandbox.io/s/create-react-app-with-typescript-6wuym?fontsize=14

See above code.

Oddly enough, the codesandbox does not show the error

Context 🔦

Trying to use makeStyles with no props. I current have to pass {} to bypass this issue.

Your Environment 🌎

Tech Version
Material-UI v4.3.0
React v16.8.6
TypeScript 3.5.3

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
knoefelcommented, Feb 15, 2021

@Phebonacci I had the same problem, all components worked, only one had the above error. I found this Answer, which said, that the createStyles function call is not necessary anymore. So i deleted it and just returned the style object from the makeStyles function call. Then the error disappeared.

1reaction
MarkMurphycommented, Sep 18, 2019

I still seem to be having this issue using a fresh cra install. "strict": true is the default.

Read more comments on GitHub >

github_iconTop Results From Across the Web

makeStyles always requires props · Issue #16867 - GitHub
An argument for 'props' was not provided for the useStyles class. Expected Behavior. makeStyles which does not use props should not require ......
Read more >
Passing props to MUI styles - reactjs - Stack Overflow
Since you are accessing props inside styles function so if the styles is defined inside react component then only props will be available...
Read more >
Global Styling with Material-UI Theme Overrides and Props
Learn how to use global CSS overrides and default props in a theme to customize all instances of a Material-UI component in a...
Read more >
React & Material UI #3: makeStyles - YouTube
How does Material UI makeStyles work? ... MUI makeStyles with themes and props - makeStyles vs withStyles The Forge Coding ...
Read more >
Material-UI makeStyles, useStyles, createStyles, and ...
Here's a final makeStyles (MUI v4) example that passes a props object to makeStyles, uses the default theme, and requires TypeScript typing ...
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