mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 07:05:11 +00:00
fix(nuxt): keep state
in the initial state instead of extracting it (#7567)
This commit is contained in:
parent
c1ed6ecc3c
commit
1ebdef77a6
@ -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)
|
||||
})
|
||||
})
|
||||
|
@ -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 }
|
||||
}
|
||||
}
|
||||
|
@ -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*\}/
|
||||
)
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user