Commit 0f3fecfe authored by Matt Hamlin's avatar Matt Hamlin Committed by Tim Neutkens

Update emotion examples with new API for SSR and React endpoint (#2456)

* Update emotion examples with new API for SSR and React endpoint

* Actually fixing tab replacement
parent 5a840cc3
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
"start": "next start" "start": "next start"
}, },
"dependencies": { "dependencies": {
"emotion": "^4.1.2", "emotion": "^5.0.0",
"next": "^2.4.6", "next": "^2.4.6",
"react": "^15.6.1", "react": "^15.6.1",
"react-dom": "^15.6.1" "react-dom": "^15.6.1"
......
import Document, { Head, Main, NextScript } from 'next/document' import Document, { Head, Main, NextScript } from 'next/document'
import { renderStaticOptimized } from 'emotion/server' import { extractCritical } from 'emotion/server'
export default class MyDocument extends Document { export default class MyDocument extends Document {
static getInitialProps ({ renderPage }) { static getInitialProps ({ renderPage }) {
const page = renderPage() const page = renderPage()
const styles = renderStaticOptimized(() => page.html) const styles = extractCritical(page.html)
return { ...page, ...styles } return { ...page, ...styles }
} }
......
import React from 'react' import React from 'react'
import { hydrate, keyframes, fragment, injectGlobal } from 'emotion' import { hydrate, keyframes, fragment, injectGlobal } from 'emotion'
import styled from 'emotion/styled' import styled from 'emotion/react'
// Adds server generated styles to emotion cache. // Adds server generated styles to emotion cache.
// '__NEXT_DATA__.ids' is set in '_document.js' // '__NEXT_DATA__.ids' is set in '_document.js'
...@@ -69,15 +69,11 @@ export default () => { ...@@ -69,15 +69,11 @@ export default () => {
return ( return (
<div> <div>
<Basic> <Basic>Cool Styles</Basic>
Cool Styles
</Basic>
<Combined> <Combined>
With <code>:hover</code>. With <code>:hover</code>.
</Combined> </Combined>
<Animated animation={bounce}> <Animated animation={bounce}>Let's bounce.</Animated>
Let's bounce.
</Animated>
</div> </div>
) )
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment