withWidth does not pass theme prop further
See original GitHub issueWhen wrapping withWidth
with withTheme
, theme
property does not appear. I checked the source and I believe this is because of that line
https://github.com/mui-org/material-ui/blob/f46b77827cbecad926eb113bad0fb6a695f94e40/src/utils/withWidth.js#L84
I suppose it should check somehow if theme prop should be passed further.
I’m using 1.0.0-beta.24 version.
Here is a small example of the issue (typescript)
function Test(props: WithTheme) {
return (
<div>
{JSON.stringify(props)} // no theme property here
</div>
);
}
let MobileDialog = withWidth()<WithTheme>(Test);
let WTheme = withTheme()(MobileDialog);
class App extends React.Component {
render() {
return (
<div className="App" style={{padding: 16}}>
<WTheme/>
</div>
);
}
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
withWidth does not pass theme prop further #9538 - GitHub
I suppose it should check somehow if theme prop should be passed further. I'm using 1.0.0-beta.24 version. Here is a small example of...
Read more >Passing props to MUI styles - reactjs - Stack Overflow
Solution for how to use both props and theme in material ui : const useStyles = props => makeStyles( theme => ({ div:...
Read more >Advanced Usage - styled-components
You can also pass a function for the theme prop. This function will receive the parent theme, that is from another <ThemeProvider> higher...
Read more >Theming in React with Styled Components | by Ross Bulat
This documentation should not be confused with styled-theming . The section does however demonstrate how we can use props to pass theme styles...
Read more >Advanced (LEGACY) - MUI System
Add a ThemeProvider to the top level of your app to pass a theme down the React component tree. Then, you can access...
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
I thinkI figured it out, I needed to pass props like so:
export default withMobileDialog<Props>()(InformationDialog);
@CharlieIGG, thanks, this saved me a ton of aggravation 😃