-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(nuxt): keep state
in initial state instead of extracting it
#7567
Conversation
β Deploy Preview for nuxt3-docs canceled.
|
I would suggest not treating data differently from state. It's also equally likely that users who have deliberately duplicated an asyncData key, such as (for example) an auto key defined in I agree we shouldn't override keys that are already defined. |
We might instead introduce new |
I've raised a separate PR partially dealing with the issue of conflicting state/data keys: #7574. If we really need to exclude data from payload, then what about, instead, only excluding data that has been set outside of a vue component instance? E.g. in a plugin. We could define on (I'm still not convinced that removing state from the payload is the right solution, as the |
I thought about making differentiated behavior too but honestly, it makes composable behavior even more unpredictable if it behaves different when used in plugin or component contexts. Actually, I made New |
I would really appreciate it if you would wait an hour or two for me to write down my comments on this and #7569. |
tldr; I think it's safe to disable the inclusion of I think there are several use-cases for it at the moment.
With this change, |
Thanks for the nice summary and input @danielroe β€οΈ Indeed this revert a short-lived behavior change we introduced in RC.10 for payload extraction making |
π Linked issue
Resolves nuxt/nuxt#14927
β Type of change
π Description
#6455 adds
payload.state
(set byuseState
) to the extracted payload. This will cause hydration and unwanted behavior on navigation by orriding already initialized state.This PR, makes behavior closer to Nuxt 2 by keeping state to the initial state inlined in the pages. Only payload data is now extracted.
Alternatives: We could instead keep extracting state and only try to set keys that are not assigned yet but it seems wrong performance wise if state is initial state it should be set once and if is same across pages, loading it adds to network overhead. We can revise it later with some better approach to only record state change diffs and include that in
_payload.js
somehow.π Checklist