Skip to content

Commit 321e0b6

Browse files
committed
fix(start): remove debug log that causes dehydration errors
The debug 'Injected from Server: ' logs are not properly escaped, causing dehydration to fail. These logs have been removed. <ScriptOnce/> debug logs are removed, and the 'tsr-once' class name set on <ScriptOnce/> elements has an extraneous space suffixed to it which has been removed as well.
1 parent eb4f882 commit 321e0b6

File tree

3 files changed

+5
-20
lines changed

3 files changed

+5
-20
lines changed

packages/react-router/src/ScriptOnce.tsx

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,18 @@
22
export function ScriptOnce({
33
className,
44
children,
5-
log,
65
...rest
7-
}: { children: string; log?: boolean } & React.HTMLProps<HTMLScriptElement>) {
6+
}: { children: string } & React.HTMLProps<HTMLScriptElement>) {
87
if (typeof document !== 'undefined') {
98
return null
109
}
1110

1211
return (
1312
<script
1413
{...rest}
15-
className={`tsr-once ${className || ''}`}
14+
className={['tsr-once', className].filter(Boolean).join(' ')}
1615
dangerouslySetInnerHTML={{
17-
__html: [
18-
children,
19-
(log ?? true) && process.env.NODE_ENV === 'development'
20-
? `console.info(\`Injected From Server:
21-
${children}\`)`
22-
: '',
23-
]
24-
.filter(Boolean)
25-
.join('\n'),
16+
__html: [children].filter(Boolean).join('\n'),
2617
}}
2718
/>
2819
)

packages/react-router/src/router.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2558,15 +2558,10 @@ export class Router<
25582558
)
25592559

25602560
this.streamedKeys.add(key)
2561-
const children = `__TSR__.streamedValues['${key}'] = { value: ${this.serializer?.(this.options.transformer.stringify(value))}}`
2561+
const children = `__TSR__.streamedValues['${key}'] = { value: ${this.serializer?.(this.options.transformer.stringify(value))} }`
25622562

25632563
this.injectHtml(
2564-
`<script class='tsr-once'>${children}${
2565-
process.env.NODE_ENV === 'development'
2566-
? `; console.info(\`Injected From Server:
2567-
${children}\`)`
2568-
: ''
2569-
}; __TSR__.cleanScripts()</script>`,
2564+
`<script class='tsr-once'>${children}; __TSR__.cleanScripts()</script>`,
25702565
)
25712566
}
25722567

packages/start/src/client/Meta.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ export const useMetaElements = () => {
118118
))}
119119
<>
120120
<ScriptOnce
121-
log={false}
122121
children={`
123122
__TSR__ = {
124123
matches: [],

0 commit comments

Comments
 (0)