@ihabdevteam/core 0.9.5 → 0.9.6
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.
- package/dist/components.cjs.js +165 -165
- package/dist/components.esm.js +166 -166
- package/dist/ihabdevteam-core.cjs.js +33 -33
- package/dist/ihabdevteam-core.esm.js +34 -34
- package/dist/packages/core/src/components/SplashLogo.js +13 -3
- package/package.json +2 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect } from 'react';
|
|
4
|
+
import { useLatestRef } from '../hooks/useLatestRef';
|
|
4
5
|
import './SplashLogo.css';
|
|
5
6
|
/**
|
|
6
7
|
* 앱에 처음 들어올 때 로고를 한 번 보여 주는 연출.
|
|
@@ -22,11 +23,20 @@ import './SplashLogo.css';
|
|
|
22
23
|
* @public
|
|
23
24
|
*/
|
|
24
25
|
export default function SplashLogo({ logo, alt, onDone, durationMs = 3000, }) {
|
|
26
|
+
// onDone 을 의존성에 그대로 두면 **다시 그릴 때마다 타이머가 새로 걸린다.** 부모가
|
|
27
|
+
// durationMs 보다 자주 다시 그리면 스플래시가 영영 안 끝난다 — 자료를 받아오는 동안
|
|
28
|
+
// 앱 뿌리가 다시 그리는 것은 흔한 일이고, 그게 바로 스플래시가 떠 있는 때다.
|
|
29
|
+
// 실측: 인라인 화살표로 다섯 번 다시 그리니 새 타이머 5개·취소 5회. 같은 콜백이면 0.
|
|
30
|
+
//
|
|
31
|
+
// 게다가 이 파일 위 예시가 `onDone={() => setShowSplash(false)}` 다 — 권하는 꼴이
|
|
32
|
+
// 곧 덫에 걸리는 꼴이었다. 그래서 부르는 쪽에 안정된 콜백을 요구하는 대신 여기서
|
|
33
|
+
// 담는다. 타이머는 한 번만 걸고, 울릴 때 **그때의 최신 콜백**을 부른다.
|
|
34
|
+
const onDoneRef = useLatestRef(onDone);
|
|
25
35
|
useEffect(() => {
|
|
26
|
-
if (!
|
|
36
|
+
if (!onDoneRef.current)
|
|
27
37
|
return;
|
|
28
|
-
const timer = setTimeout(
|
|
38
|
+
const timer = setTimeout(() => onDoneRef.current?.(), durationMs);
|
|
29
39
|
return () => clearTimeout(timer);
|
|
30
|
-
}, [
|
|
40
|
+
}, [durationMs, onDoneRef]);
|
|
31
41
|
return (_jsx("div", { className: "splash-logo", style: { ['--splash-logo-duration']: `${durationMs}ms` }, "aria-hidden": "true", children: _jsx("img", { src: logo, alt: alt, className: "splash-logo__image" }) }));
|
|
32
42
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ihabdevteam/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "dist/ihabdevteam-core.cjs.js",
|
|
6
6
|
"module": "dist/ihabdevteam-core.esm.js",
|
|
@@ -101,6 +101,7 @@
|
|
|
101
101
|
"prepare": "npm run build",
|
|
102
102
|
"prepublishOnly": "npm run build && npm run audit:exports && npm pack --dry-run > /dev/null",
|
|
103
103
|
"dev": "vite serve playground --config playground/vite.config.ts",
|
|
104
|
+
"typecheck:playground": "tsc -p playground/tsconfig.json --noEmit",
|
|
104
105
|
"build-playground": "vite build playground --config playground/vite.config.js",
|
|
105
106
|
"preview-playground": "vite preview --outDir playground/dist",
|
|
106
107
|
"smoke-test": "node ./scripts/smoke-test.js",
|