kriasoft/isomorphic-style-loader

Incompatible with React 16.6 New Context API Shortcut

dphrag opened this issue · 2 comments

React 16.6 introduced:

static contextType = MyContext;

as a shortcut to the Consumer/Provider Context API. This creates a property of convenience this.context

Putting this in a component that uses withStyles() throws:

TypeError: Cannot read property 'insertCss' of undefined
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);

I assume because there is a conflict between the property name "context"

I think that's because isomorphic-style-loader still uses React Legacy Context API, not new one. #141 will fix the problem.

Hope it is fixed #141, please reopen if it is not.