fix: improved pinia support (#1571)
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
watch,
|
||||
onServerPrefetch,
|
||||
getCurrentScope,
|
||||
getCurrentInstance,
|
||||
onScopeDispose,
|
||||
nextTick,
|
||||
shallowRef,
|
||||
@@ -152,6 +153,7 @@ export function useQueryImpl<
|
||||
lazy = false,
|
||||
): UseQueryReturn<TResult, TVariables> {
|
||||
const currentScope = getCurrentScope()
|
||||
const currentInstance = getCurrentInstance()
|
||||
|
||||
const currentOptions = ref<UseQueryOptions<TResult, TVariables>>()
|
||||
|
||||
@@ -200,7 +202,7 @@ export function useQueryImpl<
|
||||
firstRejectError = undefined
|
||||
}
|
||||
|
||||
currentScope && onServerPrefetch?.(() => {
|
||||
currentInstance && onServerPrefetch?.(() => {
|
||||
if (!isEnabled.value || (isServer && currentOptions.value?.prefetch === false)) return
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Ref, watch, onUnmounted, ref, getCurrentScope, onScopeDispose } from 'vue-demi'
|
||||
import { Ref, watch, ref, getCurrentScope, onScopeDispose } from 'vue-demi'
|
||||
import { isServer } from './env.js'
|
||||
|
||||
import type { EffectScope } from 'vue-demi'
|
||||
@@ -36,7 +36,7 @@ export function getCurrentTracking () {
|
||||
subscriptions: ref(0),
|
||||
})
|
||||
// Cleanup
|
||||
onUnmounted(() => {
|
||||
onScopeDispose(() => {
|
||||
globalTracking.components.delete(currentScope)
|
||||
})
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user