commit: 790a22c
When using a computed() that returns an array as the key, the data ref is never updated even though the fetcher successfully resolves and the cache is correctly populated.
const id = ref('user-1')
const { data } = useSWRV(
computed(() => ['/api/user', id.value]), // Returns NEW array each time
(_endpoint, userId) => fetchUser(userId)
)
In src/use-swrv.ts:128, the mutate() function uses direct reference comparison (===) to filter refs:
let refs = stateRef.data.filter(r => r.key === key)
However, when using a computed() key that returns an array, each evaluation creates a new array instance. While SWRVCache.serializeKey() correctly hashes the array (so cache lookup works), the === comparison fails because:
suggest fix:
- let refs = stateRef.data.filter(r => r.key === key)
+ const _key = cache.serializeKey(key);
+ let refs = stateRef.data.filter(r => cache.serializeKey(r.key) === _key)
When using a
computed()that returns an array as the key, thedataref is never updated even though the fetcher successfully resolves and the cache is correctly populated.In
src/use-swrv.ts:128, themutate()function uses direct reference comparison (===) to filter refs:However, when using a
computed()key that returns an array, each evaluation creates a new array instance. WhileSWRVCache.serializeKey()correctly hashes the array (so cache lookup works), the===comparison fails because:suggest fix: