This repository was archived by the owner on Dec 5, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 11import { isRef , onServerPrefetch } from '@vue/composition-api'
22import type { Ref } from '@vue/composition-api'
33
4+ import { globalNuxt } from './globals'
45import { ssrRef } from './ssr-ref'
56
67/**
@@ -39,7 +40,12 @@ export const useAsync = <T>(
3940
4041 const _ref = isRef ( key ) ? key : ssrRef < T | null > ( null , key )
4142
42- if ( ! _ref . value ) {
43+ if (
44+ ! _ref . value ||
45+ ( process . env . NODE_ENV === 'development' &&
46+ process . client &&
47+ window [ globalNuxt ] . context . isHMR )
48+ ) {
4349 const p = cb ( )
4450
4551 if ( p instanceof Promise ) {
Original file line number Diff line number Diff line change 11import { ref , computed } from '@vue/composition-api'
22import type { Ref } from '@vue/composition-api'
33
4- import { globalContext } from './globals'
4+ import { globalContext , globalNuxt } from './globals'
55
66function getValue < T > ( value : T | ( ( ) => T ) ) : T {
77 if ( value instanceof Function ) return value ( )
@@ -48,6 +48,12 @@ export const ssrRef = <T>(value: T | (() => T), key?: string): Ref<T> => {
4848 }
4949
5050 if ( process . client ) {
51+ if (
52+ process . env . NODE_ENV === 'development' &&
53+ window [ globalNuxt ] . context . isHMR
54+ ) {
55+ return ref ( getValue ( value ) )
56+ }
5157 return ref (
5258 ( window as any ) [ globalContext ] ?. ssrRefs ?. [ key ] ?? getValue ( value )
5359 )
@@ -120,6 +126,12 @@ export const shallowSsrRef = <T>(
120126 }
121127
122128 if ( process . client ) {
129+ if (
130+ process . env . NODE_ENV === 'development' &&
131+ window [ globalNuxt ] . context . isHMR
132+ ) {
133+ return shallowRef ( getValue ( value ) )
134+ }
123135 return shallowRef (
124136 ( window as any ) [ globalContext ] ?. ssrRefs ?. [ key ] ?? getValue ( value )
125137 )
You can’t perform that action at this time.
0 commit comments