From e9f5f015b7184a3aba103863330b6813125ab15c Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Tue, 5 Dec 2023 14:33:08 +0100 Subject: [PATCH] RSC: Use Routes.tsx for (client-side) routing (#9630) --- __fixtures__/test-project-rsa/web/src/Routes.tsx | 15 ++++++++++++--- .../test-project-rsa/web/src/entry.client.tsx | 16 ++-------------- .../web/src/Routes.tsx | 15 ++++++++++++--- .../web/src/entry.client.tsx | 16 ++-------------- .../templates/rsc/Routes.tsx.template | 15 ++++++++++++--- .../templates/rsc/entry.client.tsx.template | 16 ++-------------- 6 files changed, 42 insertions(+), 51 deletions(-) diff --git a/__fixtures__/test-project-rsa/web/src/Routes.tsx b/__fixtures__/test-project-rsa/web/src/Routes.tsx index 3ed60721de24..89a1df33eef0 100644 --- a/__fixtures__/test-project-rsa/web/src/Routes.tsx +++ b/__fixtures__/test-project-rsa/web/src/Routes.tsx @@ -7,13 +7,22 @@ // 'src/pages/HomePage/HomePage.js' -> HomePage // 'src/pages/Admin/BooksPage/BooksPage.js' -> AdminBooksPage -import { Router, Route } from '@redwoodjs/router' +import { Router, Route, Set } from '@redwoodjs/router' +import { serve } from '@redwoodjs/vite/client' + +import NavigationLayout from './layouts/NavigationLayout/NavigationLayout' +import NotFoundPage from './pages/NotFoundPage/NotFoundPage' + +const AboutPage = serve('AboutPage') +const HomePage = serve('HomePage') const Routes = () => { return ( - - + + + + ) diff --git a/__fixtures__/test-project-rsa/web/src/entry.client.tsx b/__fixtures__/test-project-rsa/web/src/entry.client.tsx index f6d17f5aed82..b7c0b5061610 100644 --- a/__fixtures__/test-project-rsa/web/src/entry.client.tsx +++ b/__fixtures__/test-project-rsa/web/src/entry.client.tsx @@ -1,30 +1,18 @@ import { createRoot } from 'react-dom/client' -import { Route, Router, Set } from '@redwoodjs/router' -import { serve } from '@redwoodjs/vite/client' import { FatalErrorBoundary } from '@redwoodjs/web' -import NavigationLayout from './layouts/NavigationLayout/NavigationLayout' import FatalErrorPage from './pages/FatalErrorPage/FatalErrorPage' -import NotFoundPage from './pages/NotFoundPage/NotFoundPage' +import Routes from './Routes' const redwoodAppElement = document.getElementById('redwood-app') -const AboutPage = serve('AboutPage') -const HomePage = serve('HomePage') - const root = createRoot(redwoodAppElement) const App = () => { return ( - - - - - - - + ) } diff --git a/__fixtures__/test-project-rsc-external-packages/web/src/Routes.tsx b/__fixtures__/test-project-rsc-external-packages/web/src/Routes.tsx index 3ed60721de24..89a1df33eef0 100644 --- a/__fixtures__/test-project-rsc-external-packages/web/src/Routes.tsx +++ b/__fixtures__/test-project-rsc-external-packages/web/src/Routes.tsx @@ -7,13 +7,22 @@ // 'src/pages/HomePage/HomePage.js' -> HomePage // 'src/pages/Admin/BooksPage/BooksPage.js' -> AdminBooksPage -import { Router, Route } from '@redwoodjs/router' +import { Router, Route, Set } from '@redwoodjs/router' +import { serve } from '@redwoodjs/vite/client' + +import NavigationLayout from './layouts/NavigationLayout/NavigationLayout' +import NotFoundPage from './pages/NotFoundPage/NotFoundPage' + +const AboutPage = serve('AboutPage') +const HomePage = serve('HomePage') const Routes = () => { return ( - - + + + + ) diff --git a/__fixtures__/test-project-rsc-external-packages/web/src/entry.client.tsx b/__fixtures__/test-project-rsc-external-packages/web/src/entry.client.tsx index f6d17f5aed82..b7c0b5061610 100644 --- a/__fixtures__/test-project-rsc-external-packages/web/src/entry.client.tsx +++ b/__fixtures__/test-project-rsc-external-packages/web/src/entry.client.tsx @@ -1,30 +1,18 @@ import { createRoot } from 'react-dom/client' -import { Route, Router, Set } from '@redwoodjs/router' -import { serve } from '@redwoodjs/vite/client' import { FatalErrorBoundary } from '@redwoodjs/web' -import NavigationLayout from './layouts/NavigationLayout/NavigationLayout' import FatalErrorPage from './pages/FatalErrorPage/FatalErrorPage' -import NotFoundPage from './pages/NotFoundPage/NotFoundPage' +import Routes from './Routes' const redwoodAppElement = document.getElementById('redwood-app') -const AboutPage = serve('AboutPage') -const HomePage = serve('HomePage') - const root = createRoot(redwoodAppElement) const App = () => { return ( - - - - - - - + ) } diff --git a/packages/cli/src/commands/experimental/templates/rsc/Routes.tsx.template b/packages/cli/src/commands/experimental/templates/rsc/Routes.tsx.template index 3ed60721de24..89a1df33eef0 100644 --- a/packages/cli/src/commands/experimental/templates/rsc/Routes.tsx.template +++ b/packages/cli/src/commands/experimental/templates/rsc/Routes.tsx.template @@ -7,13 +7,22 @@ // 'src/pages/HomePage/HomePage.js' -> HomePage // 'src/pages/Admin/BooksPage/BooksPage.js' -> AdminBooksPage -import { Router, Route } from '@redwoodjs/router' +import { Router, Route, Set } from '@redwoodjs/router' +import { serve } from '@redwoodjs/vite/client' + +import NavigationLayout from './layouts/NavigationLayout/NavigationLayout' +import NotFoundPage from './pages/NotFoundPage/NotFoundPage' + +const AboutPage = serve('AboutPage') +const HomePage = serve('HomePage') const Routes = () => { return ( - - + + + + ) diff --git a/packages/cli/src/commands/experimental/templates/rsc/entry.client.tsx.template b/packages/cli/src/commands/experimental/templates/rsc/entry.client.tsx.template index f6d17f5aed82..b7c0b5061610 100644 --- a/packages/cli/src/commands/experimental/templates/rsc/entry.client.tsx.template +++ b/packages/cli/src/commands/experimental/templates/rsc/entry.client.tsx.template @@ -1,30 +1,18 @@ import { createRoot } from 'react-dom/client' -import { Route, Router, Set } from '@redwoodjs/router' -import { serve } from '@redwoodjs/vite/client' import { FatalErrorBoundary } from '@redwoodjs/web' -import NavigationLayout from './layouts/NavigationLayout/NavigationLayout' import FatalErrorPage from './pages/FatalErrorPage/FatalErrorPage' -import NotFoundPage from './pages/NotFoundPage/NotFoundPage' +import Routes from './Routes' const redwoodAppElement = document.getElementById('redwood-app') -const AboutPage = serve('AboutPage') -const HomePage = serve('HomePage') - const root = createRoot(redwoodAppElement) const App = () => { return ( - - - - - - - + ) }