-
-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(nuxt3): handle hydration for error
and pending
state
#2130
Conversation
βοΈ Deploy Preview for nuxt3-docs canceled. π¨ Explore the source changes: cebd845 π Inspect the deploy log: https://app.netlify.com/sites/nuxt3-docs/deploys/619e96a8e7e17a000737e00a |
By changing flatten structure of payload into
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (didn't locally test hydration changes hope is good :D)
error
and pending
values in asyncData stateerror
and pending
state
const { error } = await useFetch('https://jsonplaceholder.typicode.com/404'); This line of code can run on both server and client with the same result and I can say that the server error for this action is already public so it was completely unrelated to Nuxt. I just want to get the http status code(404 in this case) and those recent commits transformed it from |
@@ -39,7 +40,7 @@ export default (ctx, inject) => { | |||
globalName: 'nuxt', | |||
payload: proxiedState(process.client ? ctx.nuxtState : ctx.ssrContext.nuxt), | |||
_asyncDataPromises: [], | |||
isHydrating: ctx.isHMR, | |||
isHydrating: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change also fixes bug, where useLazyAsyncData
was called again on client side during hydration.
π Linked issue
resolves nuxt/nuxt#12885
resolves nuxt/bridge#174
β Type of change
π Description
This PR includes pending/error state within the payload. Otherwise a page that (for example) checked
v-if="error"
would fail to hydrate between client/server. Because we're including pending state as well, we can use that to detect whether we need to refetch data on client side.π Checklist