kriasoft / isomorphic-style-loader

CSS style loader for Webpack that is optimized for isomorphic (universal) web apps.
https://reactstarter.com
MIT License
1.27k stars 144 forks source link

TypeError: Cannot read property 'apply' of undefined #130

Open sesn opened 6 years ago

sesn commented 6 years ago

Error:

WithStyles.componentWillMount
node_modules/isomorphic-style-loader/lib/withStyles.js:71
  68 |   value: function componentWillMount() {
  69 |     var _context;
  70 | 
> 71 |     this.removeCss = (_context = this.context).insertCss.apply(_context, styles);
  72 |   }
  73 | }, {
  74 |   key: 'componentWillUnmount',
View compiled
callComponentWillMount
node_modules/react-dom/cjs/react-dom.development.js:6872
  6869 | var oldState = instance.state;
  6870 | 
  6871 | if (typeof instance.componentWillMount === 'function') {
> 6872 |   instance.componentWillMount();
  6873 | }
  6874 | if (typeof instance.UNSAFE_componentWillMount === 'function') {
  6875 |   instance.UNSAFE_componentWillMount();
View compiled

Environment

{
    "isomorphic-style-loader": "^4.0.0",
    "react": "^16.3.2",
    "react-dom": "^16.3.2",
    "react-inlinesvg": "^0.8.1",
    "react-motion": "^0.5.2",
    "react-scripts": "1.1.4"
}
archr commented 6 years ago

You have to configure your app with the context api. Take a look at this:

https://github.com/kriasoft/react-starter-kit/blob/master/src/client.js#L24 https://github.com/kriasoft/react-starter-kit/blob/master/src/components/App.js#L53

orenyakobi commented 6 years ago

Having the same issue. The app is configured with context.

piglovesyou commented 6 years ago

If the context is correctly configured, this.context.insertCss must be passed and implemented. Please check that again.