Replies: 3 comments
-
How do you use |
Beta Was this translation helpful? Give feedback.
-
The simplest case is to not store data in cache for certain paths or query params. This is easy when key is just a simple string ( However when it's an array ( |
Beta Was this translation helpful? Give feedback.
-
@koba04 The result of executing fetcher with key For example imagine I'd want to store items in cache only when To inspect the key (path and query in example above) I can either try to decode stableHash, or access the
|
Beta Was this translation helpful? Give feedback.
-
Bug report
Description / Observed Behavior
I'm using custom cache provider to persist data in IDB.
When implementing garbage collector I'm evaluating given path (as in example).
This works fine for cases when key argument just is simple path.
However for more complex scenarios when key arguments consists of path and query I'd like to have an option to evaluate them.
SWR v2.0 has changed the structure of cached data and added
_k
property which contains key arguments:swr/core/use-swr.ts
Lines 97 to 100 in 69105b4
However the
_k
property is not part of the State interface:swr/_internal/types.ts
Lines 288 to 293 in 69105b4
Assuming the prefix means that accessing this property is not recommended, I cannot rely on it being available in future versions of the library.
Expected Behavior
The
_k
property is included in the State interface and it's unprefixed:export type State<Data = any, Error = any> = { data?: Data error?: Error isValidating?: boolean isLoading?: boolean + key?: Key }
Repro Steps / Code Example
SWR 2.0 branch for the IndexedDB Cache Provider
Additional Context
SWR version: 2.0.0-rc.0
Beta Was this translation helpful? Give feedback.
All reactions