Skip to content

Commit

Permalink
RSC: getLocation in ServerRouter (redwoodjs#10759)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe authored Jun 9, 2024
1 parent b1b58bd commit 2e72321
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 28 deletions.
9 changes: 2 additions & 7 deletions __fixtures__/test-project-rsa/web/src/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,13 @@ import Routes from './Routes'
interface Props {
css: string[]
meta?: TagDescriptor[]
location: {
pathname: string
hash?: string
search?: string
}
}

export const ServerEntry: React.FC<Props> = ({ css, meta, location }) => {
export const ServerEntry: React.FC<Props> = ({ css, meta }) => {
return (
<Document css={css} meta={meta}>
<App>
<Routes location={location} />
<Routes />
</App>
</Document>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,13 @@ import Routes from './Routes'
interface Props {
css: string[]
meta?: TagDescriptor[]
location: {
pathname: string
hash?: string
search?: string
}
}

export const ServerEntry: React.FC<Props> = ({ css, meta, location }) => {
export const ServerEntry: React.FC<Props> = ({ css, meta }) => {
return (
<Document css={css} meta={meta}>
<App>
<Routes location={location} />
<Routes />
</App>
</Document>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,13 @@ import Routes from './Routes'
interface Props {
css: string[]
meta?: TagDescriptor[]
location: {
pathname: string
hash?: string
search?: string
}
}

export const ServerEntry: React.FC<Props> = ({ css, meta, location }) => {
export const ServerEntry: React.FC<Props> = ({ css, meta }) => {
return (
<Document css={css} meta={meta}>
<App>
<Routes location={location} />
<Routes />
</App>
</Document>
)
Expand Down
1 change: 1 addition & 0 deletions packages/router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"dependencies": {
"@babel/runtime-corejs3": "7.24.5",
"@redwoodjs/auth": "workspace:*",
"@redwoodjs/server-store": "workspace:*",
"core-js": "3.37.1"
},
"devDependencies": {
Expand Down
12 changes: 5 additions & 7 deletions packages/router/src/server-router.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { ReactNode } from 'react'
import React from 'react'

import { getLocation } from '@redwoodjs/server-store'

import { analyzeRoutes } from './analyzeRoutes'
import type { Wrappers } from './analyzeRoutes'
import type { LocationContextType } from './location'
import { namedRoutes } from './namedRoutes'
import { normalizePage } from './page'
import type { RouterContextProviderProps } from './router-context'
Expand All @@ -17,14 +18,11 @@ export interface RouterProps
trailingSlashes?: TrailingSlashesTypes
pageLoadingDelay?: number
children: ReactNode
location: LocationContextType
}

export const Router: React.FC<RouterProps> = ({
paramTypes,
children,
location,
}) => {
export const Router: React.FC<RouterProps> = ({ paramTypes, children }) => {
const location = getLocation()

const analyzedRoutes = analyzeRoutes(children, {
currentPathName: location.pathname,
// @TODO We haven't handled this with SSR/Streaming yet.
Expand Down
1 change: 1 addition & 0 deletions packages/router/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"include": ["src", "./ambient.d.ts"],
"references": [
{ "path": "../auth/tsconfig.build.json" },
{ "path": "../server-store" },
]
}
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8592,6 +8592,7 @@ __metadata:
"@babel/core": "npm:^7.22.20"
"@babel/runtime-corejs3": "npm:7.24.5"
"@redwoodjs/auth": "workspace:*"
"@redwoodjs/server-store": "workspace:*"
"@testing-library/jest-dom": "npm:6.4.5"
"@types/react": "npm:^18.2.55"
"@types/react-dom": "npm:^18.2.19"
Expand Down

0 comments on commit 2e72321

Please sign in to comment.