File tree Expand file tree Collapse file tree 8 files changed +9
-42
lines changed
react-start/selective-ssr/src/routes
solid-start/selective-ssr/src/routes Expand file tree Collapse file tree 8 files changed +9
-42
lines changed Original file line number Diff line number Diff line change @@ -42,13 +42,6 @@ export const Route = createRootRoute({
4242 }
4343 } ,
4444 beforeLoad : ( { search } ) => {
45- if ( typeof window !== 'undefined' ) {
46- if ( Route . options . ssr !== undefined ) {
47- const error = `ssr() for ${ Route . id } should have been deleted from the Route options on the client`
48- console . error ( error )
49- throw new Error ( error )
50- }
51- }
5245 console . log (
5346 `beforeLoad for ${ Route . id } called on the ${ typeof window !== 'undefined' ? 'client' : 'server' } ` ,
5447 )
Original file line number Diff line number Diff line change @@ -15,13 +15,6 @@ export const Route = createFileRoute('/posts/$postId')({
1515 }
1616 } ,
1717 beforeLoad : ( { search } ) => {
18- if ( typeof window !== 'undefined' ) {
19- if ( Route . options . ssr !== undefined ) {
20- const error = `ssr() for ${ Route . id } should have been deleted from the Route options on the client`
21- console . error ( error )
22- throw new Error ( error )
23- }
24- }
2518 console . log (
2619 `beforeLoad for ${ Route . id } called on the ${ typeof window !== 'undefined' ? 'client' : 'server' } ` ,
2720 )
Original file line number Diff line number Diff line change @@ -15,13 +15,6 @@ export const Route = createFileRoute('/posts')({
1515 }
1616 } ,
1717 beforeLoad : ( { search } ) => {
18- if ( typeof window !== 'undefined' ) {
19- if ( Route . options . ssr !== undefined ) {
20- const error = `ssr() for ${ Route . id } should have been deleted from the Route options on the client`
21- console . error ( error )
22- throw new Error ( error )
23- }
24- }
2518 console . log (
2619 `beforeLoad for ${ Route . id } called on the ${ typeof window !== 'undefined' ? 'client' : 'server' } ` ,
2720 )
Original file line number Diff line number Diff line change @@ -42,13 +42,6 @@ export const Route = createRootRoute({
4242 }
4343 } ,
4444 beforeLoad : ( { search } ) => {
45- if ( typeof window !== 'undefined' ) {
46- if ( Route . options . ssr !== undefined ) {
47- const error = `ssr() for ${ Route . id } should have been deleted from the Route options on the client`
48- console . error ( error )
49- throw new Error ( error )
50- }
51- }
5245 console . log (
5346 `beforeLoad for ${ Route . id } called on the ${ typeof window !== 'undefined' ? 'client' : 'server' } ` ,
5447 )
Original file line number Diff line number Diff line change @@ -15,13 +15,6 @@ export const Route = createFileRoute('/posts/$postId')({
1515 }
1616 } ,
1717 beforeLoad : ( { search } ) => {
18- if ( typeof window !== 'undefined' ) {
19- if ( Route . options . ssr !== undefined ) {
20- const error = `ssr() for ${ Route . id } should have been deleted from the Route options on the client`
21- console . error ( error )
22- throw new Error ( error )
23- }
24- }
2518 console . log (
2619 `beforeLoad for ${ Route . id } called on the ${ typeof window !== 'undefined' ? 'client' : 'server' } ` ,
2720 )
Original file line number Diff line number Diff line change @@ -15,13 +15,6 @@ export const Route = createFileRoute('/posts')({
1515 }
1616 } ,
1717 beforeLoad : ( { search } ) => {
18- if ( typeof window !== 'undefined' ) {
19- if ( Route . options . ssr !== undefined ) {
20- const error = `ssr() for ${ Route . id } should have been deleted from the Route options on the client`
21- console . error ( error )
22- throw new Error ( error )
23- }
24- }
2518 console . log (
2619 `beforeLoad for ${ Route . id } called on the ${ typeof window !== 'undefined' ? 'client' : 'server' } ` ,
2720 )
Original file line number Diff line number Diff line change @@ -1446,6 +1446,7 @@ export class RouterCore<
14461446
14471447 match = {
14481448 id : matchId ,
1449+ ssr : this . isServer ? undefined : route . options . ssr ,
14491450 index,
14501451 routeId : route . id ,
14511452 params : previousMatch
Original file line number Diff line number Diff line change @@ -136,6 +136,12 @@ export async function hydrate(router: AnyRouter): Promise<any> {
136136 }
137137 }
138138
139+ function setRouteSsr ( match : AnyRouteMatch ) {
140+ const route = router . looseRoutesById [ match . routeId ]
141+ if ( route ) {
142+ route . options . ssr = match . ssr
143+ }
144+ }
139145 // Right after hydration and before the first render, we need to rehydrate each match
140146 // First step is to reyhdrate loaderData and __beforeLoadContext
141147 let firstNonSsrMatchIndex : number | undefined = undefined
@@ -146,10 +152,12 @@ export async function hydrate(router: AnyRouter): Promise<any> {
146152 if ( ! dehydratedMatch ) {
147153 match . _nonReactive . dehydrated = false
148154 match . ssr = false
155+ setRouteSsr ( match )
149156 return
150157 }
151158
152159 hydrateMatch ( match , dehydratedMatch )
160+ setRouteSsr ( match )
153161
154162 match . _nonReactive . dehydrated = match . ssr !== false
155163
You can’t perform that action at this time.
0 commit comments