outerTheme from MuiThemeProvider is null
See original GitHub issue- I have searched the issues of this repository and believe that this is not a duplicate.
Expected Behavior
When passing a function as the theme
prop to MuiThemeProvider
the first parameter of that function is outerTheme
. outerTheme
should contain the actual theme properties.
Current Behavior
outerTheme
is null
. Trying to access any property gives an error (of course): Cannot read property 'whatever' of null
.
Steps to Reproduce (for bugs)
Even the official example from the docs doesn’t work:
function theme(outerTheme) {
return createMuiTheme({
typography: {
fontFamily:
'-apple-system,system-ui,BlinkMacSystemFont,' +
'"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif',
body1: {
fontWeight: outerTheme.typography.fontWeightMedium, // <-- Cannot read property 'typography' of null
},
button: {
fontStyle: 'italic',
},
},
});
}
Check it out on CodeSandbox.
Context
I wanted to overwrite the line height of body2
with the line height of body1
Your Environment
Tech | Version |
---|---|
Material-UI | 1.0.0-beta.23 |
React | 16.2.0 |
browser | Chrome 63.0.3239.84 |
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
outerTheme from MuiThemeProvider is null #9507 - GitHub
outerTheme is null . Trying to access any property gives an error (of course): Cannot read property 'whatever' of null . Steps to...
Read more >Error in MuiThemeProvider - reactjs - Stack Overflow
I'm facing a problem in a react project. When executing the project, I get the following error: "Failed prop type: The prop 'theme'...
Read more >Styles API - MUI System
When set to null , it follows theme.direction . The other keys are forwarded to the options ... You can provide a function...
Read more >Material UI Theme Provider not being included properly in ...
MuiThemeProvider.render(): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid ...
Read more >Package Diff: @material-ui/styles @ 4.0.0-alpha.7 .. 4.0.0-beta.0
[️MuiThemeProvider] TypeScript disableStylesGeneration (#10759) @djeeg. - [Input] Relax inputProps and ... + const output = outerTheme === null ?
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
Hum actually in order to no make the bundle size grow. I’m wondering if the best option isn’t to add a warning when the outerTheme is missing and not changing the behavior.
@nikoladev Your solution looks good. I have added a warning an updated the demos example so we can run in it codesandbox. One more though. Having codesandbox is a great tool for identifying demos that can’t be copy&paste.