Skip to content

Commit

Permalink
bug: SSR page data not escaped correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
iksaku committed May 21, 2023
1 parent fd077e8 commit 42cc11a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/createInertiaApp.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Page, PageResolver, setupProgress } from '@inertiajs/core'
import { renderTags } from '@solidjs/meta'
import { createComponent, generateHydrationScript, isServer, renderToString } from 'solid-js/web'
import { Dynamic, createComponent, generateHydrationScript, isServer, renderToString } from 'solid-js/web'
import App, { InertiaAppProps } from './App'

type CreateInertiaBaseOptions = {
Expand Down Expand Up @@ -54,9 +54,14 @@ export default async function createInertiaApp({
}

if (isServer) {
const body = `<div id='${id}' data-page='${JSON.stringify(initialPage)}'>${renderToString(() =>
createComponent(App, props),
)}</div>`
const body = renderToString(() =>
createComponent(Dynamic, {
component: 'div',
children: createComponent(App, props),
id,
'data-page': JSON.stringify(initialPage),
}),
)

const head = renderTags(props.head).concat(generateHydrationScript())

Expand Down

0 comments on commit 42cc11a

Please sign in to comment.