@withStyles + required propType checks shows warning
See original GitHub issuenot sure when this started happening but it wasnt happening before. when using decorators for withStyles and checking for the classes
prop inside the class i get the following error
Warning: Failed prop type: The prop `classes` is marked as required in `withStyles(MyModule)`, but its value is `undefined`.
same explanation using code:
const styles = theme => (...)
// works and shows warning
@withStyles(styles)
export default class MyModule extends Component {
static propTypes = {
classes: PropTypes.object.isRequired,
}
...
}
// works without warning
class MyModule extends Component {
static propTypes = {
classes: PropTypes.object.isRequired,
}
...
}
export default withStyles(styles)(LoginModule)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
withStyles + required propType checks shows warning #9456
Warning: Failed prop type: The prop `classes` is marked as required in `withStyles(MyModule)`, but its value is `undefined`.
Read more >PropType not giving warning - Stack Overflow
I am trying to use PropTypes to give a warning if they are not the correct type, or if they do not exist...
Read more >Typechecking With PropTypes - React
In this example, we're using PropTypes. string . When an invalid value is provided for a prop, a warning will be shown in...
Read more >material-ui/core/CHANGELOG.md - UNPKG
Each warning comes with a simple message that explains how to handle the ... 1739, - [CardMedia] Use propTypes for "at least one"-check...
Read more >How To Style React Components | DigitalOcean
The alert component will take any number of children. This means you will need to be cautious about style conflicts, since you have...
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 FreeTop 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
Top GitHub Comments
Here are the relevant entries:
Looks like
classes
is undefined in constructor. So the decorator injectclasses
on mount.