Skip to content

Commit

Permalink
run all dynamic validation through prerenders
Browse files Browse the repository at this point in the history
  • Loading branch information
gnoff committed Oct 20, 2024
1 parent 14aae73 commit d12c98d
Show file tree
Hide file tree
Showing 19 changed files with 521 additions and 632 deletions.
26 changes: 6 additions & 20 deletions packages/next/src/client/components/client-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,13 @@ export function ClientPageRoot({
)
}

if (store.isStaticGeneration) {
// We are in a prerender context
const { createPrerenderSearchParamsFromClient } =
require('../../server/request/search-params') as typeof import('../../server/request/search-params')
clientSearchParams = createPrerenderSearchParamsFromClient(store)
const { createSearchParamsFromClient } =
require('../../server/request/search-params') as typeof import('../../server/request/search-params')
clientSearchParams = createSearchParamsFromClient(searchParams, store)

const { createPrerenderParamsFromClient } =
require('../../server/request/params') as typeof import('../../server/request/params')

clientParams = createPrerenderParamsFromClient(params, store)
} else {
const { createRenderSearchParamsFromClient } =
require('../../server/request/search-params') as typeof import('../../server/request/search-params')
clientSearchParams = createRenderSearchParamsFromClient(
searchParams,
store
)
const { createRenderParamsFromClient } =
require('../../server/request/params') as typeof import('../../server/request/params')
clientParams = createRenderParamsFromClient(params, store)
}
const { createParamsFromClient } =
require('../../server/request/params') as typeof import('../../server/request/params')
clientParams = createParamsFromClient(params, store)

return <Component params={clientParams} searchParams={clientSearchParams} />
} else {
Expand Down
10 changes: 2 additions & 8 deletions packages/next/src/client/components/client-segment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,10 @@ export function ClientSegmentRoot({
)
}

const { createPrerenderParamsFromClient } =
const { createParamsFromClient } =
require('../../server/request/params') as typeof import('../../server/request/params')
clientParams = createParamsFromClient(params, store)

if (store.isStaticGeneration) {
clientParams = createPrerenderParamsFromClient(params, store)
} else {
const { createRenderParamsFromClient } =
require('../../server/request/params') as typeof import('../../server/request/params')
clientParams = createRenderParamsFromClient(params, store)
}
return <Component {...slots} params={clientParams} />
} else {
const { createRenderParamsFromClient } =
Expand Down
Loading

0 comments on commit d12c98d

Please sign in to comment.