From 0a8341e162bc9d2a4017c05efba4d5dad0daf84c Mon Sep 17 00:00:00 2001 From: Craig Harshbarger Date: Mon, 14 Oct 2024 20:41:36 -0500 Subject: [PATCH] Use a watch rather than a watchEffect --- src/useStorage/useStorage.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/useStorage/useStorage.ts b/src/useStorage/useStorage.ts index f158c8b8..fe273888 100644 --- a/src/useStorage/useStorage.ts +++ b/src/useStorage/useStorage.ts @@ -1,5 +1,4 @@ -/* eslint-disable no-redeclare */ -import { ref, Ref, UnwrapRef, watchEffect } from 'vue' +import { ref, Ref, UnwrapRef, watch } from 'vue' import { StorageManager, StorageType } from '@/useStorage/storage' type UseStorage = { @@ -34,13 +33,13 @@ export function useStorage(type: StorageType, key: string, defaultValue: T | data.value = value } - watchEffect(() => { + watch(data, value => { if (stopped) { console.warn(`Storage for key ${key} as been removed and cannot be updated`) return } - storage.set(key, data.value) + storage.set(key, value) }) return {