v1.0.5-beta.007 - Resolve infinite render loop and API spam on library page
This commit fixes a severe infinite re-render cycle on the Library page that was causing continuous, rapid requests to the /api/library and /api/library/collections endpoints.
The issue was caused by a dependency loop between Next.js router state (useSearchParams), browser history mutations (window.history.replaceState), and React's useEffect tracking.
Specific changes made:
- Implemented useRef for filter state tracking ( iltersRef) to decouple data-fetching logic from React's dependency scanner, keeping the loadLibraryData function perfectly stable.
- Replaced useSearchParams with native window.location.search during the initial mount to prevent the Next.js router from forcing component teardowns when the URL changes.
- Added lazy state initialization for localStorage values (pageSize, �iewMode) to prevent double-renders on component mount.
- Stabilized the oast utility using a ref ( oastRef) to prevent external library reference changes from triggering effects.
- Decoupled the initial on mount data fetch from the on filter change data fetch.