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

Error: StyleContext.Provider #168

Open Greatwallycc opened 5 years ago

Greatwallycc commented 5 years ago

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 (

{React.Children.only(this.props.children)}
)

} }

export default hot(App);

frenzzy commented 5 years ago
- import StyleContext from 'isomorphic-style-loader';
+ import StyleContext from 'isomorphic-style-loader/StyleContext';
Greatwallycc commented 5 years ago

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)

Greatwallycc commented 5 years ago

Sorry, it's my fault, i installed it at version 4.0.