makeStyles always requires props
See original GitHub issuemakeStyles 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:
- Created 4 years ago
- Comments:11 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@Phebonacci I had the same problem, all components worked, only one had the above error. I found this Answer, which said, that the
createStylesfunction call is not necessary anymore. So i deleted it and just returned the style object from themakeStylesfunction call. Then the error disappeared.I still seem to be having this issue using a fresh cra install.
"strict": trueis the default.