Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/OnyxSnapshotCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ class OnyxSnapshotCache {
* Other options like `reuseConnection` don't affect the data transformation
* or timing behavior of getSnapshot, so they're excluded from the cache key for better cache hit rates.
*/
registerConsumer<TKey extends OnyxKey, TReturnValue>(options: Pick<UseOnyxOptions<TKey, TReturnValue>, 'selector'>): string {
registerConsumer<TKey extends OnyxKey, TReturnValue>(key: TKey, options: Pick<UseOnyxOptions<TKey, TReturnValue>, 'selector'>): string {
const selectorID = options?.selector ? this.getSelectorID(options.selector) : 'no_selector';
const cacheKey = String(selectorID);
const cacheKey = `${key}_${selectorID}`;

// Increment reference count for this cache key
const currentCount = this.cacheKeyRefCounts.get(cacheKey) || 0;
Expand Down
4 changes: 2 additions & 2 deletions lib/useOnyx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ function useOnyx<TKey extends OnyxKey, TReturnValue = OnyxValue<TKey>>(
// Cache the options key to avoid regenerating it every getSnapshot call
const cacheKey = useMemo(
() =>
onyxSnapshotCache.registerConsumer({
onyxSnapshotCache.registerConsumer(key, {
selector: options?.selector,
}),
[options?.selector],
[key, options?.selector],
);

useEffect(() => () => onyxSnapshotCache.deregisterConsumer(key, cacheKey), [key, cacheKey]);
Expand Down
Loading
Loading