I get a 'style._insertCss' is not a function error
See original GitHub issueHi, I use react to test with create-react-app v2.1.5 For serverside rendering with scss, css styles.
the app is applied to basic sample on create-react-app. just eject and add code on the Webpack
rules: [
{
test: /\.css$/,
use: [
'isomorphic-style-loader',
{
loader: 'css-loader',
options: {
importLoaders: 1
}
},
'postcss-loader'
]
},
///************more code****************///
also App.js
import React, { Component } from 'react';
import logo from './logo.svg';
import s from './App.scss';
import withStyles from 'isomorphic-style-loader/withStyles'
class App extends Component {
render() {
return (
<div className={s.App}>
<header className={s.Appheader}>
<img src={logo} className={s.Applogo} alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className={s.Applink}
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
}
export default withStyles(s)(App);
finally Index.js
import React from 'react';
import ReactDOM from 'react-dom';
// import './index.css';
import StyleContext from 'isomorphic-style-loader/StyleContext'
import App from './App';
import * as serviceWorker from './serviceWorker';
const insertCss = (...styles) => {
const removeCss = styles.map(style => style._insertCss())
return () => removeCss.forEach(dispose => dispose())
}
ReactDOM.hydrate(
<StyleContext.Provider value={{ insertCss }}>
<App />,
</StyleContext.Provider>,
document.getElementById('root')
);
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: http://bit.ly/CRA-PWA
serviceWorker.unregister();
that’s it, What is miss ? could you please let me know what I miss. thanks
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (5 by maintainers)
Top Results From Across the Web
Chrome Extension to change Style Elements, insertCSS not ...
I tried using insertCSS in the content.js but read that it will not work from there but should from a popup or background...
Read more >Chrome Extension to change Style Elements ... - Google Groups
I now get a new error: Error handling response: TypeError: Error in invocation of scripting.insertCSS(scripting.CSSInjection injection, optional function ...
Read more >tabs.insertCSS() - Mozilla - MDN Web Docs
This is an asynchronous function that returns a Promise (on Firefox only). Syntax. let inserting = browser.tabs.insertCSS( ...
Read more >tabs.insertCSS()
... function onError(error) { console.log(`Error: ${error}`); } var insertingCSS = browser.tabs.insertCSS(2, {file: "content-style.css"}); ...
Read more >How to add CSS - W3Schools
Three Ways to Insert CSS. There are three ways of inserting a style sheet: External CSS; Internal CSS; Inline CSS. External CSS. With ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You have this problem because you did not add isomorphic-style-loader to your webpack client build. 1. You should eject your app and update config or 2. install react-app-rewired and add additional config for css or scss rules.
You can play with it here https://github.com/VeXell/ssr/tree/created_with_react_scripts
Client needs to be configured,reference resources