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: __webpack_require__.i(...) is not a function when using createMuiTheme #7238

Closed
krismartin opened this issue Jun 24, 2017 · 18 comments
Assignees
Labels
bug 🐛 Something doesn't work
Milestone

Comments

@krismartin
Copy link

I'm getting TypeError: __webpack_require__.i(...) is not a function error when calling the createMuiTheme. I followed the example code from https://material-ui-1dab0.firebaseapp.com/customization/themes.

const theme = createMuiTheme({
  palette: createPalette({
    primary: purple, // Purple and green play nicely together.
    accent: {
      ...green,
      A400: '#00e677',
    },
    error: red,
  }),
});

Versions

  • Material-UI: 1.0.0-alpha.19
  • React: 15.6.1
  • Browser: Chrome 58.0.3029.110
@oliviertassinari
Copy link
Member

Can you share the stack trace of the issue?

@oliviertassinari oliviertassinari added the waiting for 👍 Waiting for upvotes label Jun 24, 2017
@krismartin
Copy link
Author

This is very strange. It is working now without changing anything. Just did a browser refresh and I'm not getting the error anymore.

@oliviertassinari
Copy link
Member

Feel free to reopen the issue if you can provide a reproduction test case then. Sounds like a issue on webpack land.

@krismartin
Copy link
Author

krismartin commented Jun 25, 2017

@oliviertassinari While I got you here, I have a question regarding theme customization.

I'm trying to change the primary color to blue, which works fine, except the focused input fields and labels still have the old color as you can see below:

screen shot 2017-06-25 at 8 33 08 pm

Here's my theme:

import { blue } from 'material-ui/styles/colors';

const muiTheme = createMuiTheme({
  palette: createPalette({
    primary: blue,
  })
});

@oliviertassinari
Copy link
Member

I think that it's expected, we use the accent hue of the primary color. Try out a different color to see that behavior.

@krismartin
Copy link
Author

How do you recommend changing the color of the focused input fields and labels to be the same as the primary color?

@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 25, 2017

How do you recommend changing the color of the focused input fields and labels

The easier one would be the change the A700 hues of the blue color. The more elegant one would be to overrides the MuiInput.inkbar&:after->backgroundColor style as well as MuiFormLabel.focused->color.

@krismartin
Copy link
Author

Thank you. I'll give that a shot.

@krismartin
Copy link
Author

@oliviertassinari I can't seem to figure out where to put the css overrides (MuiInput.inkbar&:after->backgroundColor and MuiFormLabel.focused->color). Can you give me some example please?

@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 29, 2017

Here is an example mixing two approach: https://www.webpackbin.com/bins/-KnpurLIGtBVrZx27iEL

const styleSheet = createStyleSheet('HelloWorld', theme => ({
  inkbar: {
    '&:after': {
      backgroundColor: 'red'
    }
  }
}))

const HelloWorld = (props) => (
  <TextField label="hello" InputProps={{classes: props.classes}} />
)

export default withStyles(styleSheet)(HelloWorld);

// ...

import { MuiThemeProvider, createMuiTheme } from 'material-ui/styles';

const theme = createMuiTheme({
  overrides: {
    MuiFormLabel: {
      focused: {
        color: 'red'
      }
    }
  }
});

@krismartin
Copy link
Author

krismartin commented Jul 1, 2017

Thank you @oliviertassinari. That is very helpful.

I can get the overriding of MuiFormLabel.focused color working using the createMuiTheme, but the MuiInput.inkbar&:after override doesn't seem to be working.

Here's my code:

const muiTheme = createMuiTheme({
  palette: createPalette({
    primary: blue,
  }),
  overrides: {
    MuiFormLabel: {
      focused: {
        color: 'red'
      }
    },
    MuiInput: {
      inkbar: {
        '&:after': {
          backgroundColor: 'red'
        }
      }
    }
  }
});

I can see the style has been applied properly to the element in dev tool:

screen shot 2017-07-01 at 10 33 27 am

But I don't see the red underline when I focus on the field:

screen shot 2017-07-01 at 10 34 18 am

@oliviertassinari
Copy link
Member

the MuiInput.inkbar&:after override doesn't seem to be working.

@krismartin I confirm, there is an issue here

@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work and removed waiting for 👍 Waiting for upvotes labels Jul 14, 2017
@oliviertassinari oliviertassinari added this to the v1.0.0-beta milestone Jul 14, 2017
@oliviertassinari oliviertassinari self-assigned this Jul 17, 2017
@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 22, 2017

@krismartin We are doing a deep merge now. I'm expecting the issue to be fixed.

@rachit1994
Copy link

rachit1994 commented Jul 30, 2017

I am facing the same problem but it is not getting resolved on browser refresh.
I am using React-boilerplate I created a MUIContainer and wrapped the App inside MuiThemeProvider

import React from 'react';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import withProgressBar from 'components/ProgressBar';
import theme from './material_ui_raw_theme_file';
import App from '../App';


export function MuiContainer(props) {
  return (
    <MuiThemeProvider muiTheme={theme}>
      <App {...props} />
    </MuiThemeProvider>
    );
}

MuiContainer.propTypes = {
  children: React.PropTypes.node,
};

export default withProgressBar(MuiContainer);

material_ui_raw_theme_file:

import { fade } from 'material-ui/styles/colorManipulator'
import * as Colors from 'material-ui/colors';
import { spacing, getMuiTheme } from 'material-ui/styles';

console.log('colors', Colors);

const rawBaseTheme = {
  ...spacing,
  palette: {
    primary: Colors.blue,
    accent: Colors.green,
    textColor: Colors.common.darkBlack,
    alternateTextColor: Colors.common.white,
    canvasColor: Colors.common.white,
    borderColor: Colors.grey,
    disabledColor: fade(Colors.common.darkBlack, 0.3)
  }
};

//Theme must be wrapped in funciton getMuiTheme
export default getMuiTheme(rawBaseTheme);

I am getting the error from getMuiTheme. webpack version: 2.2.0-rc.3
error:

Uncaught TypeError: __webpack_require__.i(...) is not a function
    at eval (eval at ./app/containers/MuiContainer/material_ui_raw_theme_file.js (main.js:1054), <anonymous>:28:131)
    at Object../app/containers/MuiContainer/material_ui_raw_theme_file.js (main.js:1054)
    at __webpack_require__ (main.js:687)
    at fn (main.js:106)
    at eval (eval at ./app/containers/MuiContainer/index.js (main.js:1046), <anonymous>:6:86)
    at Object../app/containers/MuiContainer/index.js (main.js:1046)
    at __webpack_require__ (main.js:687)
    at fn (main.js:106)
    at eval (eval at ./app/app.js (main.js:791), <anonymous>:21:83)
    at Object../app/app.js (main.js:791)

@tonven
Copy link

tonven commented Aug 17, 2017

Getting same error after I updated from 1.0.0-beta.3 to 1.0.0-beta.5.
Here is the code:

import * as React from 'react';
import AppBar from 'material-ui/AppBar';
import Toolbar from 'material-ui/Toolbar';
import Button from 'material-ui/Button';
import IconButton from 'material-ui/IconButton';
import Typography from 'material-ui/Typography';
import MenuIcon from 'material-ui-icons/Menu';
import { withStyles, createStyleSheet } from 'material-ui/styles';

const styleSheet = createStyleSheet('Header', {
    root: {
        width: '100%',
    },
    flex: {
        flex: 1,
    },
});

const Logged = (props) => (
    <MenuIcon
        {...props}
        iconButtonElement={
            <IconButton></IconButton>
        }
        targetOrigin={{ horizontal: 'right', vertical: 'top' }}
        anchorOrigin={{ horizontal: 'right', vertical: 'top' }}
    >
        <MenuIcon primaryText="Refresh" />
        <MenuIcon primaryText="Help" />
        <MenuIcon primaryText="Sign out" />
    </MenuIcon>
);


function Header(props) {
    const classes = props.classes;
    return (<div>
        <AppBar position="static" className={classes.root}>
            <Toolbar>
                <Typography type="title" color="inherit" className={classes.flex}>
                    Predictor
                    </Typography>
                <Button color="contrast">Sign up</Button>
                <Button color="contrast">Login</Button>
            </Toolbar>
        </AppBar>
    </div>);
}

export default withStyles(styleSheet)(Header);

@oliviertassinari
Copy link
Member

@Tonvengo have a look at the CHANGELOG.

@tonven
Copy link

tonven commented Aug 17, 2017 via email

@leon-yum
Copy link

leon-yum commented Nov 6, 2017

What is the fix for this bug? I'm still running into it: https://stackoverflow.com/questions/47019815/material-ui-getmuitheme-missing-after-upgrading-from-0-9-to-1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work
Projects
None yet
Development

No branches or pull requests

5 participants