Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: new mui.Styles.ThemeManager() is not a function #1810

Closed
nickzuber opened this issue Oct 6, 2015 · 4 comments
Closed

TypeError: new mui.Styles.ThemeManager() is not a function #1810

nickzuber opened this issue Oct 6, 2015 · 4 comments
Labels
customization: theme Centered around the theming features package: styles Specific to @mui/styles. Legacy package, @material-ui/styled-engine is taking over in v5.

Comments

@nickzuber
Copy link

I have a simple React component here, and when I try to load this code I get an error:

const ThemeManager = new mui.Styles.ThemeManager();
                     ^
TypeError: object is not a function
...

This is the code that I currently have. Can anyone help figure out what might be causing this weird error?

const React = require('react');
const injectTapEventPlugin = require("react-tap-event-plugin");
injectTapEventPlugin();
const mui = require('material-ui');

const List = mui.List;
const ListDivider = mui.ListDivider;
const ListItem = mui.ListItem;
const FontIcon = mui.FontIcon;
const RaisedButton = mui.RaisedButton;

// This line is throwing an error
const ThemeManager = new mui.Styles.ThemeManager();


const SideBar = React.createClass({

  childContextTypes: {
    muiTheme: React.PropTypes.object
  },

  getChildContext: function() {
    return {
      muiTheme: ThemeManager.getCurrentTheme()
    };
  },

  render: function(){

    return(
      <div className='sidebar'>
        <RaisedButton label="Primary" primary={true} />
        <List>
          <ListItem primaryText="Inbox" />
          <ListItem primaryText="Starred" />
          <ListItem primaryText="Sent mail" />
          <ListItem primaryText="Drafts" />
        </List>
        <ListDivider />
        <List>
          <ListItem primaryText="All mail" />
          <ListItem primaryText="Trash" />
          <ListItem primaryText="Spam" />
          <ListItem primaryText="Follow up" />
        </List>
      </div>
    );
  }

});

module.exports.SideBar = SideBar;
@bdefore
Copy link

bdefore commented Oct 6, 2015

ThemeManager has a new API in 0.12. you no longer use a constructor. see http://material-ui.com/#/customization/themes

@nickzuber
Copy link
Author

Okay, thank you for the help! @bdefore

@maksadbek
Copy link

I am getting this kind of warnings, elements are stopped working(onClick)

Warning: owner-based and parent-based contexts differ (values: `undefined` vs `[object Object]`) for key (muiTheme) while mounting IconButton (see: http://fb.me/react-context-by-parent)

@alitaheri
Copy link
Member

Seems like this issue is resolved.

mnajdova pushed a commit to mnajdova/material-ui that referenced this issue Nov 10, 2020
Bumps [@types/sinon](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/sinon) from 7.5.1 to 9.0.4.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/sinon)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
@zannager zannager added package: styles Specific to @mui/styles. Legacy package, @material-ui/styled-engine is taking over in v5. customization: theme Centered around the theming features labels Dec 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customization: theme Centered around the theming features package: styles Specific to @mui/styles. Legacy package, @material-ui/styled-engine is taking over in v5.
Projects
None yet
Development

No branches or pull requests

5 participants