@appcorp/fusion-storybook 0.1.78 → 0.1.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -423,8 +423,18 @@ export const useClassModule = () => {
423
423
  // ============================================================================
424
424
  // 1.4.9 EFFECTS
425
425
  // ============================================================================
426
- // Initial load via cache; re-fetch directly from API on page/pageLimit/filter/search changes
426
+ // Always keep the ref current so the main effect can call the latest listFetchNow
427
+ // without including it in the dependency array (listFetchNow changes identity every
428
+ // render because useModuleEntityV2 passes an inline headers object to useFetch).
429
+ // Declared first so the ref is populated before the fetch effect runs.
427
430
  useEffect(() => {
431
+ listFetchNowRef.current = listFetchNow;
432
+ });
433
+ // Initial load via cache; re-fetch directly from API on page/pageLimit/filter/search changes.
434
+ // listFetchNow is intentionally excluded from deps — it changes every render due to the
435
+ // inline headers object in useModuleEntityV2. We call it via the stable ref instead.
436
+ useEffect(() => {
437
+ var _a;
428
438
  if (!schoolId)
429
439
  return;
430
440
  const currentPage = Number(listParams.currentPage) || 1;
@@ -450,14 +460,11 @@ export const useClassModule = () => {
450
460
  })();
451
461
  }
452
462
  else {
453
- // Bypass cache for pagination, pageLimit, filter and search changes
454
- listFetchNow();
463
+ // Bypass cache for pagination, pageLimit, filter and search changes.
464
+ // Use ref to avoid the infinite-loop caused by listFetchNow's unstable identity.
465
+ (_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
455
466
  }
456
- }, [dispatch, listFetchNow, listParams, schoolId, showToast, t]);
457
- // Sync ref to always point at latest listFetchNow (avoids stale closure in callbacks)
458
- useEffect(() => {
459
- listFetchNowRef.current = listFetchNow;
460
- });
467
+ }, [dispatch, listParams, schoolId, showToast, t]);
461
468
  // ============================================================================
462
469
  // 1.4.10 RETURN
463
470
  // ============================================================================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/fusion-storybook",
3
- "version": "0.1.78",
3
+ "version": "0.1.79",
4
4
  "scripts": {
5
5
  "build-storybook": "storybook build",
6
6
  "build:next": "next build",