diff --git a/app/components/LazyLoaded.tsx b/app/components/LazyLoaded.tsx deleted file mode 100644 index f3fefc9..0000000 --- a/app/components/LazyLoaded.tsx +++ /dev/null @@ -1,5 +0,0 @@ -const LazyLoaded = () => ( - I have been lazily loaded using Streaming SSR! -); - -export default LazyLoaded; diff --git a/app/components/README.md b/app/components/README.md deleted file mode 100644 index 3b05428..0000000 --- a/app/components/README.md +++ /dev/null @@ -1,3 +0,0 @@ -## Components - -You can place your own components in this folder or just delete it. It only exists for demonstrating purposes only. diff --git a/app/entry.client.tsx b/app/entry.client.tsx index 40dbe7e..77dbd4c 100644 --- a/app/entry.client.tsx +++ b/app/entry.client.tsx @@ -1,4 +1,4 @@ -import { hydrateRoot } from 'react-dom/client'; +import { hydrate } from 'react-dom'; import { RemixBrowser } from '@remix-run/react'; -hydrateRoot(document, ); +hydrate(, document); diff --git a/app/entry.server.tsx b/app/entry.server.tsx index 8f7e2a0..ae8e56a 100644 --- a/app/entry.server.tsx +++ b/app/entry.server.tsx @@ -1,42 +1,21 @@ -import { renderToReadableStream } from 'react-dom/server'; +import { renderToString } from 'react-dom/server'; import type { EntryContext } from '@remix-run/cloudflare'; import { RemixServer } from '@remix-run/react'; -import isbot from 'isbot'; -export default async function handleRequest( +export default function handleRequest( request: Request, responseStatusCode: number, responseHeaders: Headers, remixContext: EntryContext ) { - const controller = new AbortController(); + const markup = renderToString( + + ); - try { - const stream = await renderToReadableStream( - , - { - signal: controller.signal, - onError: error => { - responseStatusCode = 500; - console.error(error); - }, - } - ); + responseHeaders.set('Content-Type', 'text/html'); - if (isbot(request.headers.get('user-agent'))) { - await stream.allReady; - } - - responseHeaders.set('Content-Type', 'text/html'); - - return new Response(stream, { - status: responseStatusCode, - headers: responseHeaders, - }); - } catch (e) { - return new Response('

Loading...

', { - status: 500, - headers: { 'Content-Type': 'text/html' }, - }); - } + return new Response('' + markup, { + status: responseStatusCode, + headers: responseHeaders, + }); } diff --git a/app/routes/index.tsx b/app/routes/index.tsx index 8fe77e8..7ba6dca 100644 --- a/app/routes/index.tsx +++ b/app/routes/index.tsx @@ -1,15 +1,4 @@ -import { lazy, Suspense, useState } from 'react'; - -const LazyLoaded = lazy(async () => { - // Artificial delay - await new Promise(resolve => setTimeout(resolve, 1000)); - - return await import('../components/LazyLoaded'); -}); - export default function Index() { - const [showLazyLoaded, setShowLazyLoaded] = useState(false); - return (

Welcome to Remix

@@ -37,17 +26,6 @@ export default function Index() { Remix Docs -
  • - {showLazyLoaded ? ( - - - - ) : ( - - )} -
  • ); diff --git a/package.json b/package.json index 1aa7203..2bc06e4 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ "@remix-run/cloudflare": "^1.4.3", "@remix-run/cloudflare-pages": "^1.4.3", "@remix-run/react": "^1.4.3", - "isbot": "^3.4.6", "react": "^18.1.0", "react-dom": "^18.1.0" }, diff --git a/tsconfig.json b/tsconfig.json index 6f29c9d..914a10e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,6 @@ { "include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"], "compilerOptions": { - "module": "es2020", "lib": ["DOM", "DOM.Iterable", "ES2019"], "isolatedModules": true, "esModuleInterop": true, diff --git a/yarn.lock b/yarn.lock index 1a0971c..fe32c2c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4379,11 +4379,6 @@ isarray@1.0.0, isarray@~1.0.0: resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= -isbot@^3.4.6: - version "3.4.6" - resolved "https://registry.yarnpkg.com/isbot/-/isbot-3.4.6.tgz#e3dd70034b6a6fad043753de71cd96929a678015" - integrity sha512-EEi3SVCPB4WHtMBaAYzYLgCP7yG9qixseYCf3IG0Yc+howLia+XFPLTT1437rzeViLeDInKOXOdFhs9Fa/xgWQ== - isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"