Error: StyleContext.Provider
Greatwallycc opened this issue · 3 comments
I get an error : UnhandledPromiseRejectionWarning: Error: Cannot find module 'isomorphic-style-loader/StyleContext'
here is the code:
import React from 'react';
import PropTypes from 'prop-types';
import {Provider} from 'react-redux';
import {ConfigProvider} from 'antd';
// import zhCN from 'antd/es/locale/zh_CN';
import zhCN from 'antd/lib/locale-provider/zh_CN';
import StyleContext from 'isomorphic-style-loader';
import {hot} from 'react-hot-loader/root';
import getStore from './store';
class App extends React.PureComponent {
static propTypes = {
children: PropTypes.element.isRequired,
}
insertCss = (...styles) => {
const removeCss = styles.map(style => style._insertCss())
return () => removeCss.forEach(dispose => dispose())
}
render () {
return (
<StyleContext.Provider value={{insertCss: this.insertCss}}>
{React.Children.only(this.props.children)}
</StyleContext.Provider>
)
}
}
export default hot(App);
- import StyleContext from 'isomorphic-style-loader';
+ import StyleContext from 'isomorphic-style-loader/StyleContext';
Thanks, but it still doesn't work.
(node:86136) UnhandledPromiseRejectionWarning: Error: Cannot find module 'isomorphic-style-loader/StyleContext'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (D:\学习\React\EDS\src\ssr/App.js:7:1)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Module._compile (D:\学习\React\EDS\node_modules\pirates\lib\index.js:99:24)
at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Object.newLoader [as .js] (D:\学习\React\EDS\node_modules\pirates\lib\index.js:104:7)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (D:\学习\React\EDS\src\ssr/SSR.js:8:1)
at Module._compile (internal/modules/cjs/loader.js:778:30)
Sorry, it's my fault, i installed it at version 4.0.