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.

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:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
oliviertassinaricommented, Dec 15, 2017

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.

0reactions
oliviertassinaricommented, Dec 16, 2017

@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.

Read more comments on GitHub >

github_iconTop 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 >

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