mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
perf(hooks): document stable reference optimization in useDefaultSubplebbits
This commit is contained in:
@@ -158,7 +158,9 @@ export const useDefaultSubplebbits = () => {
|
||||
};
|
||||
}, []);
|
||||
|
||||
// To maintain backward compatibility, return the subplebbits array directly
|
||||
// Always prefer cacheSubplebbits (module-level, stable reference) when available
|
||||
// Only use state.subplebbits during initial load before cache is populated
|
||||
// This ensures a stable reference for memoization in consuming hooks
|
||||
return cacheSubplebbits || state.subplebbits;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user