Skip to content

Commit a41208e

Browse files
committed
minor refactor
1 parent df47f2c commit a41208e

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

packages/vike-react/src/integration/onRenderClient.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ function onUncaughtErrorGlobal(
102102
}
103103
type OnUncaughtError = RootOptions['onUncaughtError']
104104
type OnUncaughtErrorArgs = Parameters<NonNullable<RootOptions['onUncaughtError']>>
105+
type OnUncaughtErrorInfo = OnUncaughtErrorArgs[1]
105106

106107
// Inject componentStack to the error's stack trace
107108
// - Server counterpart: https://github.com/brillout/react-streaming/blob/e0a6210957e65dad2c92877ad075ebac4713d8fa/src/server/renderToStream/common.ts#L93
108-
type OnUncaughtErrorInfo = OnUncaughtErrorArgs[1]
109109
function getErrorWithComponentStack(errorOriginal: unknown, errorInfo?: OnUncaughtErrorInfo) {
110110
if (!errorInfo?.componentStack || !isObject(errorOriginal)) return errorOriginal
111111
const errorStackLines = String(errorOriginal.stack).split('\n')

packages/vike-react/src/integration/onRenderHtml.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,15 @@ async function renderPageToHtml(pageContext: PageContextServer) {
8686
// @ts-ignore
8787
pageContext.userAgent
8888
// Properties are set conditionally (instead of being assigned `undefined`) to satisfy `exactOptionalPropertyTypes`.
89-
const renderOptions: RenderToStreamOptions = {}
89+
const options: RenderToStreamOptions = {}
9090
// When streamSetting.type is null: let react-streaming decide the stream type
91-
if (streamSetting.type) renderOptions.webStream = streamSetting.type === 'web'
92-
if (userAgent) renderOptions.userAgent = userAgent
91+
if (streamSetting.type) options.webStream = streamSetting.type === 'web'
92+
if (userAgent) options.userAgent = userAgent
9393
// +stream.require is true => default +stream.enable is true
9494
// +stream.require is false => default +stream.enable is false
9595
// Don't override disabling when a bot is detected.
96-
if (streamSetting.enable === false) renderOptions.disable = true
97-
Object.assign(renderOptions, renderToStreamOptions)
98-
const pageHtmlStream = await renderToStream(pageContext.page, renderOptions)
96+
if (streamSetting.enable === false) options.disable = true
97+
const pageHtmlStream = await renderToStream(pageContext.page, { ...options, ...renderToStreamOptions })
9998
pageContext.pageHtmlStream = pageHtmlStream
10099
}
101100
}

0 commit comments

Comments
 (0)