From 13e423ccf61a96dc5c0ca5e10107e368d06c376d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Fri, 9 Sep 2022 15:35:37 +0200 Subject: [PATCH] chore: fix examples (#40395) Closes #40366 Rebass is not dependent on `styled-components` anymore. See: https://rebassjs.org/migrating/#v4-breaking-changes Closes #40367 Document has been converted (#39871) from class, so `this.props` threw an error. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples) --- examples/with-rebass/.babelrc | 9 --------- examples/with-rebass/package.json | 11 ++--------- examples/with-rebass/pages/_document.js | 18 ------------------ examples/with-strict-csp/pages/_document.js | 6 +++--- 4 files changed, 5 insertions(+), 39 deletions(-) delete mode 100644 examples/with-rebass/.babelrc delete mode 100644 examples/with-rebass/pages/_document.js diff --git a/examples/with-rebass/.babelrc b/examples/with-rebass/.babelrc deleted file mode 100644 index d9c3f919cedb35d..000000000000000 --- a/examples/with-rebass/.babelrc +++ /dev/null @@ -1,9 +0,0 @@ -{ - "presets": ["next/babel"], - "plugins": [ - [ - "styled-components", - { "ssr": true, "displayName": true, "preprocess": false } - ] - ] -} diff --git a/examples/with-rebass/package.json b/examples/with-rebass/package.json index d5fd2bd64cd0834..bf29745bfe271d9 100644 --- a/examples/with-rebass/package.json +++ b/examples/with-rebass/package.json @@ -7,14 +7,7 @@ }, "dependencies": { "next": "latest", - "react": "^18.0.0", - "react-dom": "^18.0.0", - "rebass": "^4.0.7", - "styled-components": "^5.3.0" - }, - "devDependencies": { - "babel-plugin-styled-components": "^2.0.7", - "babel-plugin-transform-object-assign": "^6.22.0", - "babel-plugin-transform-object-set-prototype-of-to-assign": "^6.22.0" + "react": "^18.2.0", + "react-dom": "^18.2.0" } } diff --git a/examples/with-rebass/pages/_document.js b/examples/with-rebass/pages/_document.js deleted file mode 100644 index 2734d4e2736b33a..000000000000000 --- a/examples/with-rebass/pages/_document.js +++ /dev/null @@ -1,18 +0,0 @@ -import { Html, Head, Main, NextScript } from 'next/document' -import { ServerStyleSheet } from 'styled-components' - -export default function Document() { - const sheet = new ServerStyleSheet() - const main = sheet.collectStyles(
) - const styleTags = sheet.getStyleElement() - - return ( - - {styleTags} - -
{main}
- - - - ) -} diff --git a/examples/with-strict-csp/pages/_document.js b/examples/with-strict-csp/pages/_document.js index c65a84322801818..f85a7eaeb7ea4f4 100644 --- a/examples/with-strict-csp/pages/_document.js +++ b/examples/with-strict-csp/pages/_document.js @@ -6,13 +6,13 @@ const cspHashOf = (text) => { hash.update(text) return `'sha256-${hash.digest('base64')}'` } -export default function Document() { +export default function Document(ctx) { let csp = `default-src 'self'; script-src 'self' ${cspHashOf( - NextScript.getInlineScriptSource(this.props) + NextScript.getInlineScriptSource(ctx) )}` if (process.env.NODE_ENV !== 'production') { csp = `style-src 'self' 'unsafe-inline'; font-src 'self' data:; default-src 'self'; script-src 'unsafe-eval' 'self' ${cspHashOf( - NextScript.getInlineScriptSource(this.props) + NextScript.getInlineScriptSource(ctx) )}` }