fix(vue-app): fix asyncData hydration when features.transition: false (#6433)

This commit is contained in:
Pim 2019-09-18 15:51:22 +02:00 committed by Pooya Parsa
parent 3b9eddc223
commit ec6ef6e425

View File

@ -11,7 +11,7 @@ import {
getMatchedComponentsInstances, getMatchedComponentsInstances,
flatMapComponents, flatMapComponents,
setContext, setContext,
<% if (features.transitions) { %>getLocation,<% } %> <% if (features.transitions || features.asyncData || features.fetch) { %>getLocation,<% } %>
compile, compile,
getQueryDiff, getQueryDiff,
globalHandleError globalHandleError
@ -186,7 +186,7 @@ function mapTransitions (Components, to, from) {
} }
} }
<% if (features.transitions) { %> <% if (features.transitions || features.asyncData || features.fetch) { %>
function applySSRData (Component, ssrData) { function applySSRData (Component, ssrData) {
<% if (features.asyncData) { %> <% if (features.asyncData) { %>
if (NUXT.serverRendered && ssrData) { if (NUXT.serverRendered && ssrData) {
@ -796,6 +796,8 @@ function addHotReload ($component, depth) {
_app.setTransitions(mapTransitions(Components, router.currentRoute)) _app.setTransitions(mapTransitions(Components, router.currentRoute))
_lastPaths = router.currentRoute.matched.map(route => compile(route.path)(router.currentRoute.params)) _lastPaths = router.currentRoute.matched.map(route => compile(route.path)(router.currentRoute.params))
} }
<% } else if (features.asyncData || features.fetch) { %>
await Promise.all(resolveComponents(router))
<% } %> <% } %>
// Initialize error handler // Initialize error handler
_app.$loading = {} // To avoid error while _app.$nuxt does not exist _app.$loading = {} // To avoid error while _app.$nuxt does not exist