serverPrefetch doesn't work as expected
See original GitHub issueVersion
2.6.10
Steps to reproduce
Suppose we have a component:
export default {
data(){
return { foo: null}
}
async serverPrefetch(){
this.foo = 'serverPrefetch'
},
created(){
this.foo = 'created'
},
}
foo
is initially null, then created()
updates it to created
and this reflects in the html interpolitatiion, but when serverPrefetch() updates this.foo
it is not reflected on the rendered html, despite being called afterwards.
What is expected?
serverPrefetch() should reflect rendered and updated data variables when rendered on SSR
What is actually happening?
serverPrefetch() doesn’t update the rendered view with new data after being called
Issue Analytics
- State:
- Created 4 years ago
- Comments:36 (17 by maintainers)
Top Results From Across the Web
VueJS sever-side-rendering: computed property not seeing ...
So at (4) I tried to recreate the hard-code fetchPage by having data ready before creating the component. However I didn't expect the...
Read more >Server-Side Rendering (SSR) - Vue.js
This works as expected in a pure client-side Vue application, since the modules in our application are initialized fresh for each browser page...
Read more >Need help regarding server prefetch - Vue Storefront
Hello Everyone. i have created module to list data and create detail page for that list now i have used serverPrefetch in detail...
Read more >SQL Server Prefetch and Query Performance - Simple Talk
The following script took almost 6 mins to run in my notebook. ... I think the results will be similar, I don't expect...
Read more >Server-side rendering with Vue InstantSearch - Algolia
You can then start the development server by running npm run ssr:serve . ... in your browser, you won't see the search results...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
To conclude: your steps 2 and 4 in your diagram are not technically possible.
@DominusVilicus the code you originally posted is working as expected (per test case). By design, a component’s
serverPrefetch
should only affectdata
of its own (or child components via passed props). The only case that it “doesn’t work” is that when a component’sserverPrefetch
is mutating state that doesn’t belong to itself.