Closed ashuverma closed 2 years ago
This is to support use cases like css in js e.g. Rendering Styled Components on server
e.g. in server entry (server.js)
server
import {ServerStyleSheet} from "styled-components"; import ReactDOM from "react-dom/server"; export default { renderer(element, options) { const sheet = new ServerStyleSheet(); try { const html = ReactDOMServer.renderToString(. // This can be renderToNodeStream or Static markup/stream depending on option. sheet.collectStyles(element) ); const styleTags = sheet.getStyleTags(); return styleTags + html; } catch (error) { console.log(error); } }
@divyakarippath @jchip
This is to support use cases like css in js e.g. Rendering Styled Components on server
e.g. in
server
entry (server.js)