Skip to content

Commit

Permalink
Svelte: Don't resolve component twice on first load
Browse files Browse the repository at this point in the history
  • Loading branch information
james-em committed Apr 19, 2024
1 parent ca7e7cb commit 9c148e2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/svelte/src/createInertiaApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ export default async function createInertiaApp({ id = 'app', resolve, setup, pro
const initialPage = page || JSON.parse(el.dataset.page)
const resolveComponent = (name) => Promise.resolve(resolve(name))

await resolveComponent(initialPage.component).then((initialComponent) => {
store.set({
component: initialComponent,
page: initialPage,
})
})

if (!isServer) {
router.init({
initialPage,
Expand Down Expand Up @@ -44,6 +37,13 @@ export default async function createInertiaApp({ id = 'app', resolve, setup, pro
}

if (isServer) {
await resolveComponent(initialPage.component).then((initialComponent) => {
store.set({
component: initialComponent,
page: initialPage,
})
})

const { html, head } = SSR.render({ id, initialPage })

return {
Expand Down

0 comments on commit 9c148e2

Please sign in to comment.