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

Error: StyleContext.Provider #168

Open
Greatwallycc opened this issue Aug 29, 2019 · 3 comments
Open

Error: StyleContext.Provider #168

Greatwallycc opened this issue Aug 29, 2019 · 3 comments

Comments

@Greatwallycc
Copy link

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);

@Greatwallycc Greatwallycc changed the title Errot: StyleContext.Provider Error: StyleContext.Provider Aug 29, 2019
@frenzzy
Copy link
Member

frenzzy commented Aug 29, 2019

- import StyleContext from 'isomorphic-style-loader';
+ import StyleContext from 'isomorphic-style-loader/StyleContext';

@Greatwallycc
Copy link
Author

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants