How to await onServerPrefetch in nested components to reflect changes in the view during SSR? #12795
Unanswered
johnRivs
asked this question in
Help/Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a situation where I'm changing some
inject
'd state in a child component that the parent component relies on in its view.This is App.vue, the parent:
This is Home.vue, the child:
Let's say the count starts at 1. During SSR, everything in the parent runs, which produces
App.vue count: 2
. Then, Home.vue producesHome.vue count: 3
but I need App.vue to also reflect that change in its view. From the docs, I understand reactivity is disabled during SSR which I imagine explains why the view in the parent is not updating.I know the state itself works because after all this, I'm serializing it onto the HTML document and it does return the correct count:
window.__INITIAL_STATE__ = {"count":3};
.Is this any of this possible at all? Am I approaching it in the wrong way? I'm open to achieving the goal in a different way. Ultimately, all state changes need to have happened by the time rendering starts.
vue: 3.5.12
vite: 5.4.10
@vitejs/plugin-vue: 5.1.4
vue-router: 4.5.0
Beta Was this translation helpful? Give feedback.
All reactions