From 1ebdef77a679ba866e5fd0ad7a26452981800004 Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Fri, 16 Sep 2022 12:49:00 +0200 Subject: [PATCH] fix(nuxt): keep `state` in the initial state instead of extracting it (#7567) --- packages/nuxt/src/app/plugins/payload.client.ts | 1 - packages/nuxt/src/core/runtime/nitro/renderer.ts | 4 ++-- test/basic.test.ts | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/nuxt/src/app/plugins/payload.client.ts b/packages/nuxt/src/app/plugins/payload.client.ts index be0a711b71..c13acdb001 100644 --- a/packages/nuxt/src/app/plugins/payload.client.ts +++ b/packages/nuxt/src/app/plugins/payload.client.ts @@ -16,6 +16,5 @@ export default defineNuxtPlugin((nuxtApp) => { const payload = await loadPayload(to.path) if (!payload) { return } Object.assign(nuxtApp.payload.data, payload.data) - Object.assign(nuxtApp.payload.state, payload.state) }) }) diff --git a/packages/nuxt/src/core/runtime/nitro/renderer.ts b/packages/nuxt/src/core/runtime/nitro/renderer.ts index 7364ca49d5..ed2cc41836 100644 --- a/packages/nuxt/src/core/runtime/nitro/renderer.ts +++ b/packages/nuxt/src/core/runtime/nitro/renderer.ts @@ -297,9 +297,9 @@ function renderPayloadResponse (ssrContext: NuxtSSRContext) { } function splitPayload (ssrContext: NuxtSSRContext) { - const { data, state, prerenderedAt, ...initial } = ssrContext.payload + const { data, prerenderedAt, ...initial } = ssrContext.payload return { initial: { ...initial, prerenderedAt }, - payload: { data, state, prerenderedAt } + payload: { data, prerenderedAt } } } diff --git a/test/basic.test.ts b/test/basic.test.ts index 2e951d4f22..3d86a69d9e 100644 --- a/test/basic.test.ts +++ b/test/basic.test.ts @@ -590,7 +590,7 @@ describe.skipIf(process.env.NUXT_TEST_DEV || isWindows)('payload rendering', () it('renders a payload', async () => { const payload = await $fetch('/random/a/_payload.js', { responseType: 'text' }) expect(payload).toMatch( - /export default \{data:\{\$frand_a:\[[^\]]*\]\},state:\{"\$srandom:rand_a":\d*,"\$srandom:default":\d*\},prerenderedAt:\d*\}/ + /export default \{data:\{\$frand_a:\[[^\]]*\]\},prerenderedAt:\d*\}/ ) })