Skip to content

Commit

Permalink
RSC: Use Routes.tsx for (client-side) routing (#9630)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe authored Dec 5, 2023
1 parent 69a1770 commit e9f5f01
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 51 deletions.
15 changes: 12 additions & 3 deletions __fixtures__/test-project-rsa/web/src/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Router>
<Route path="/about" page={AboutPage} name="about" />
<Route path="/" page={HomePage} name="home" />
<Set wrap={NavigationLayout}>
<Route path="/" page={HomePage} name="home" />
<Route path="/about" page={AboutPage} name="about" />
</Set>
<Route notfound page={NotFoundPage} />
</Router>
)
Expand Down
16 changes: 2 additions & 14 deletions __fixtures__/test-project-rsa/web/src/entry.client.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<FatalErrorBoundary page={FatalErrorPage}>
<Router>
<Set wrap={NavigationLayout}>
<Route path="/" page={HomePage} name="home" />
<Route path="/about" page={AboutPage} name="about" />
</Set>
<Route notfound page={NotFoundPage} />
</Router>
<Routes />
</FatalErrorBoundary>
)
}
Expand Down
15 changes: 12 additions & 3 deletions __fixtures__/test-project-rsc-external-packages/web/src/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Router>
<Route path="/about" page={AboutPage} name="about" />
<Route path="/" page={HomePage} name="home" />
<Set wrap={NavigationLayout}>
<Route path="/" page={HomePage} name="home" />
<Route path="/about" page={AboutPage} name="about" />
</Set>
<Route notfound page={NotFoundPage} />
</Router>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -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 (
<FatalErrorBoundary page={FatalErrorPage}>
<Router>
<Set wrap={NavigationLayout}>
<Route path="/" page={HomePage} name="home" />
<Route path="/about" page={AboutPage} name="about" />
</Set>
<Route notfound page={NotFoundPage} />
</Router>
<Routes />
</FatalErrorBoundary>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Router>
<Route path="/about" page={AboutPage} name="about" />
<Route path="/" page={HomePage} name="home" />
<Set wrap={NavigationLayout}>
<Route path="/" page={HomePage} name="home" />
<Route path="/about" page={AboutPage} name="about" />
</Set>
<Route notfound page={NotFoundPage} />
</Router>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -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 (
<FatalErrorBoundary page={FatalErrorPage}>
<Router>
<Set wrap={NavigationLayout}>
<Route path="/" page={HomePage} name="home" />
<Route path="/about" page={AboutPage} name="about" />
</Set>
<Route notfound page={NotFoundPage} />
</Router>
<Routes />
</FatalErrorBoundary>
)
}
Expand Down

0 comments on commit e9f5f01

Please sign in to comment.