diff --git a/examples/with-noscript/components/Noscript.js b/examples/with-noscript/components/Noscript.js index 6dc373552ef3d86d220c23549cb06c9e8004f266..32eed3bae2fc1449bcf8506538472e55049aadb3 100644 --- a/examples/with-noscript/components/Noscript.js +++ b/examples/with-noscript/components/Noscript.js @@ -1,7 +1,15 @@ import React from 'react' -import ReactDOMServer from 'react-dom/server' -export default function Noscript (props) { - const staticMarkup = ReactDOMServer.renderToStaticMarkup(props.children) +// We don't want to send 'react-dom/server' to the client +let ReactDOMServer +if (typeof window === 'undefined') { + ReactDOMServer = require('react-dom/server') +} + +export default function Noscript ({ children }) { + if (!ReactDOMServer) { + return null + } + const staticMarkup = ReactDOMServer.renderToStaticMarkup(children) return } diff --git a/examples/with-noscript/next.config.js b/examples/with-noscript/next.config.js deleted file mode 100644 index 354682e5892c2da252890aedd43e85b529055b4e..0000000000000000000000000000000000000000 --- a/examples/with-noscript/next.config.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - webpack: (config, { dev }) => { - if (!dev) { - config.resolve.alias = { - 'react-dom/server': require.resolve( - 'react-dom/umd/react-dom-server.browser.production.min.js' - ) - } - } - return config - } -} diff --git a/examples/with-noscript/package.json b/examples/with-noscript/package.json index 1ea6403271b418ce54773dc1ba061232da722f94..e5e964b3a3a99527074be3764d410f8373578688 100644 --- a/examples/with-noscript/package.json +++ b/examples/with-noscript/package.json @@ -9,8 +9,7 @@ "dependencies": { "next": "latest", "react": "^16.7.0", - "react-dom": "^16.7.0", - "react-lazyload": "^2.2.7" + "react-dom": "^16.7.0" }, "license": "ISC" } diff --git a/examples/with-noscript/pages/index.js b/examples/with-noscript/pages/index.js index 3e1c80b7c51c5d51219651bbec48f39f5cb4ad04..d9850622f507098ecec79b5c74e3b342166345ab 100644 --- a/examples/with-noscript/pages/index.js +++ b/examples/with-noscript/pages/index.js @@ -1,35 +1,15 @@ import React from 'react' -import LazyLoad from 'react-lazyload' import Noscript from '../components/Noscript' -const images = [ - '/static/img/reactjs.png', - '/static/img/nextjs.png', - '/static/img/vuejs.png', - '/static/img/angular.jpg' -] +export default function IndexPage () { + return ( + <> +
Disable JavaScript to see it in action:
-class Index extends React.Component { - static getInitialProps (context) { - const { isServer } = context - return { isServer } - } - render () { - return ( -