Skip to content

Commit 57a7b81

Browse files
committed
assign z on useZero
1 parent f62b7bf commit 57a7b81

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/create-zero.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ import { useQueryWithZero } from './query'
88
const zeroCleanups = new Set()
99

1010
export function createZero<S extends Schema = Schema, MD extends CustomMutatorDefs | undefined = undefined>(optsOrZero: MaybeRefOrGetter<ZeroOptions<S, MD> | { zero: Zero<S, MD> }>) {
11-
const z = shallowRef() as ShallowRef<Zero<S, MD>>
11+
let z: ShallowRef<Zero<S, MD>>
12+
13+
function useZero(): ShallowRef<Zero<S, MD>> {
14+
if (!z) {
15+
z = shallowRef() as ShallowRef<Zero<S, MD>>
16+
}
1217

13-
function useZero() {
1418
if (z.value) {
1519
return z
1620
}

0 commit comments

Comments
 (0)