@ihabdevteam/core 0.9.4 → 0.9.5

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.
@@ -8,7 +8,15 @@ export interface ImgStats {
8
8
  }
9
9
  /**
10
10
  * 단어쌍 인덱스와 이미지 캐시 현황을 읽어 반환하는 훅.
11
- * `words` 의존성이 변경될 때마다 1초 뒤 갱신 (비동기 빌드 완료 대기).
11
+ * 낱말 목록이 바뀔 때마다, 그리고 1초 뒤 번 더 갱신한다(비동기 빌드 완료 대기).
12
+ *
13
+ * `words` 는 **바뀌었다는 신호로만** 쓴다 — effect 안에서 내용을 읽지 않는다. 통계는
14
+ * 모듈 레벨 인덱스에서 나온다. 그래서 길이를 신호로 삼는다. 참조로 삼으면 안 되는데,
15
+ * 통계를 담는 setState 가 매번 새 객체라 리렌더가 나고, 인라인 배열을 넘긴 호출부에서는
16
+ * 그 리렌더가 다시 새 배열을 만들어 끝나지 않는다(실측: 힙이 터졌다).
17
+ *
18
+ * 길이가 그대로인 채 내용만 통째로 바뀌는 경우는 이 신호로 못 잡는다. 그때는 돌려주는
19
+ * `refreshStats()` 를 직접 부르면 된다.
12
20
  */
13
21
  /**
14
22
  * @public
@@ -4,7 +4,15 @@ import { getPairIndex } from '../utils/wordPairIndex';
4
4
  import { getImageExistenceStats } from '../utils/imageConfig';
5
5
  /**
6
6
  * 단어쌍 인덱스와 이미지 캐시 현황을 읽어 반환하는 훅.
7
- * `words` 의존성이 변경될 때마다 1초 뒤 갱신 (비동기 빌드 완료 대기).
7
+ * 낱말 목록이 바뀔 때마다, 그리고 1초 뒤 번 더 갱신한다(비동기 빌드 완료 대기).
8
+ *
9
+ * `words` 는 **바뀌었다는 신호로만** 쓴다 — effect 안에서 내용을 읽지 않는다. 통계는
10
+ * 모듈 레벨 인덱스에서 나온다. 그래서 길이를 신호로 삼는다. 참조로 삼으면 안 되는데,
11
+ * 통계를 담는 setState 가 매번 새 객체라 리렌더가 나고, 인라인 배열을 넘긴 호출부에서는
12
+ * 그 리렌더가 다시 새 배열을 만들어 끝나지 않는다(실측: 힙이 터졌다).
13
+ *
14
+ * 길이가 그대로인 채 내용만 통째로 바뀌는 경우는 이 신호로 못 잡는다. 그때는 돌려주는
15
+ * `refreshStats()` 를 직접 부르면 된다.
8
16
  */
9
17
  /**
10
18
  * @public
@@ -34,7 +42,7 @@ export function useWordDataStats(words) {
34
42
  refreshStats();
35
43
  const t = setTimeout(refreshStats, 1000);
36
44
  return () => clearTimeout(t);
37
- }, [words, refreshStats]);
45
+ }, [words?.length, refreshStats]);
38
46
  /* eslint-enable react-hooks/set-state-in-effect */
39
47
  return { pairStats, imgStats, setPairStats, setImgStats, refreshStats };
40
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ihabdevteam/core",
3
- "version": "0.9.4",
3
+ "version": "0.9.5",
4
4
  "private": false,
5
5
  "main": "dist/ihabdevteam-core.cjs.js",
6
6
  "module": "dist/ihabdevteam-core.esm.js",