@ihabdevteam/core 0.9.2 → 0.9.3

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.
@@ -27,6 +27,15 @@ export function useWordTrainingDataGeneration(types, difficulty, contrastCount,
27
27
  const [perTypeData, setPerTypeData] = useState({});
28
28
  const [generating, setGenerating] = useState(false);
29
29
  const { cho = null, jung = null, jong = null, syllable = null } = composition ?? {};
30
+ // gradeFilter 는 **내용**으로 의존해야 한다. 배열 자체를 의존성에 넣으면 끝나지 않는다:
31
+ // 배치가 끝날 때마다 setPerTypeData 로 다시 그려지고, 그때 새 배열이 생겨 effect 가
32
+ // 또 돌고, 또 끝나고… 실측으로 아무것도 안 누른 채 1533번을 만들었다.
33
+ //
34
+ // 인자를 생략하면 특히 그렇다 — 기본값 `[]` 는 부를 때마다 새로 만들어진다.
35
+ // composition 은 cho/jung/jong/syllable 로 풀어 원시값으로 의존하고 있었는데,
36
+ // 배열인 이쪽만 빠져 있었다. effect 안에서 어차피 정렬해 문자열로 쓰고 있으니
37
+ // 그 문자열을 의존성으로 삼는다. 내용이 같으면 다시 만들지 않는다.
38
+ const gradeKey = gradeFilter.length > 0 ? gradeFilter.slice().sort().join(',') : '';
30
39
  // 단어풀 갱신 시 사전 계산 (백그라운드 fire-and-forget)
31
40
  useEffect(() => {
32
41
  if (poolVersion > 0) {
@@ -40,7 +49,6 @@ export function useWordTrainingDataGeneration(types, difficulty, contrastCount,
40
49
  setGenerating(true);
41
50
  (async () => {
42
51
  const compFilter = toCompositionFilter({ cho, jung, jong, syllable });
43
- const gradeKey = gradeFilter.length > 0 ? gradeFilter.slice().sort().join(',') : '';
44
52
  const compKey = `${cho ?? ''}_${jung ?? ''}_${jong ?? ''}_${syllable ?? ''}_${gradeKey}`;
45
53
  const results = {};
46
54
  await Promise.all(types.map(async (t) => {
@@ -92,7 +100,7 @@ export function useWordTrainingDataGeneration(types, difficulty, contrastCount,
92
100
  }
93
101
  })();
94
102
  return () => { cancelled = true; };
95
- }, [difficulty, contrastCount, cho, jung, jong, syllable, excludeNoImage, sameStructureOnly, phonemeView, poolVersion, gradeFilter]); // eslint-disable-line react-hooks/exhaustive-deps
103
+ }, [difficulty, contrastCount, cho, jung, jong, syllable, excludeNoImage, sameStructureOnly, phonemeView, poolVersion, gradeKey]); // eslint-disable-line react-hooks/exhaustive-deps
96
104
  /* eslint-enable react-hooks/set-state-in-effect */
97
105
  return { perTypeData, generating };
98
106
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ihabdevteam/core",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "private": false,
5
5
  "main": "dist/ihabdevteam-core.cjs.js",
6
6
  "module": "dist/ihabdevteam-core.esm.js",