Comments (3)
I am facing the same issue, how exactly did you import the styles? Can you elaborate on the workaround you used and also the correct solution, if you have been able to find it?
from react-ssr-lambda.
@rishit5 Hey, sorry I missed this. I ended up using styled-components to inject the CSS into the head. It was a very long and painful process to get it right.
Here's a watered down version
import ReactDOMServer from 'react-dom/server'
import { ServerStyleSheet } from 'styled-components'
import MetaTagsServer from 'react-meta-tags/server'
import { MetaTagsContext } from 'react-meta-tags'
import App from './App'
/**
* <html lang="en">
<head>
<meta charset="utf-8" />
... other head tags
META
STYLED_COMPONENTS
</head>
<body >
<div id="root"></div>
</body>
</html>
*/
import { HtmlTemplate } from './html'
export const renderApp = () => {
const Sheets = new ServerStyleSheet()
const metaTagsInstance = MetaTagsServer()
const props = {...}
const app = ReactDOMServer.renderToStaticMarkup(
Sheets.collectStyles(
<MetaTagsContext extract={metaTagsInstance.extract}>
<App {...props} />
</MetaTagsContext>,
),
)
const meta = metaTagsInstance.renderToString()
const styledComponentsTag = Sheets.getStyleTags()
const html = HtmlTemplate.replace('<div id="root"></div>', `<div id="root">${app}</div>`)
.replace('STYLED_COMPONENTS', styledComponentsTag)
.replace('META', meta)
Sheets.seal()
return html
}
from react-ssr-lambda.
Webpack 4 could not do it correctly, I am working on a new sample and will address this issue there.
from react-ssr-lambda.
Related Issues (10)
- The source code for lambda functions is not present in simple-ssr/edge-build folder HOT 1
- Data is loaded again (unnecessarily) after hydration HOT 1
- npm run build fails because of babel-loader versio mismatch HOT 1
- bash: cdk: command not found HOT 1
- home path and edgessr both got ERROR: The request could not be satisfied HOT 1
- Module not found: Can't resolve './config.json' HOT 1
- problem when deploying edge lamda function HOT 3
- Outdated python runtime is used in this repository HOT 1
- Cannot find asset issue during cdk bootstrap
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-ssr-lambda.