Skip to content

[svg-manager] SvgUniqueID를 useId 기반 SSR-safe id로 재작성#226

Draft
yongsk0066 wants to merge 6 commits into
mainfrom
feature/193-useid
Draft

[svg-manager] SvgUniqueID를 useId 기반 SSR-safe id로 재작성#226
yongsk0066 wants to merge 6 commits into
mainfrom
feature/193-useid

Conversation

@yongsk0066

Copy link
Copy Markdown
Member

Related Issue

Describe your changes

SvgUniqueID가 매 렌더 generateRandomString()으로 난수 id를 만들어 SSR↔CSR hydration 불일치를 일으키던 문제를 해결합니다.
기존 문제

  • useId 기반으로 재작성 — 서버/클라이언트에서 동일한 id가 나와 hydration-safe
  • 전역 localIdsMap 싱글톤 의존을 순수 함수 renameId()로 단순화
  • toSafeId 유틸 추가 — useId가 만드는 콜론 포함 id를 url(#...)/CSS selector에 안전한 토큰으로 정규화
  • deepMap 단순화 (중복 isValidElement 검사 제거)
  • 테스트 추가

'use client' 전환은 #194 리뷰(discussion_r2285848228)에서 정리됐듯 서버/클라 id 시작점이 달라 불가피합니다.
기존 동작은 동일하고 hydration 버그만 해결하며, client 컴포넌트를 import해도 import하는 쪽이 client가 되지는 않습니다(경계는 SvgUniqueID 서브트리 한정).

Request

@yongsk0066 yongsk0066 self-assigned this Jun 12, 2026
@npayfebot

Copy link
Copy Markdown
Collaborator

✅ Changeset detected

Latest commit: d0bea53

@naverpay/svg-manager package have detected changes.

If no version change is needed, please add skip-detect-change to the label.

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@naverpay/svg-manager 💥 Major
powered by: naverpay changeset detect-add actions

@npayfebot

Copy link
Copy Markdown
Collaborator

NPM Packages

📦 @naverpay/svg-manager

Total Sizes: 2.19 kB

Total Changes: -1.98 kB (-47%) ✅ (Size Decreased)

File Status Previous Size Updated Size Changed
/dist/esm/index.mjs 🛠️ 122 B 88 B -34 B (-28%)
/dist/esm/SvgUniqueID.mjs 🛠️ 758 B 570 B -188 B (-25%)
/dist/esm/utils/index.mjs 🔥 375 B - -375 B
/dist/esm/utils/getSecureMathRandom.mjs 🔥 455 B - -455 B
/dist/esm/utils/deepMap.mjs 🛠️ 308 B 283 B -25 B (-8%)
/dist/cjs/index.js 🛠️ 177 B 150 B -27 B (-15%)
/dist/cjs/SvgUniqueID.js 🛠️ 765 B 571 B -194 B (-25%)
/dist/cjs/utils/index.js 🔥 442 B - -442 B
/dist/cjs/utils/getSecureMathRandom.js 🔥 458 B - -458 B
/dist/cjs/utils/deepMap.js 🛠️ 313 B 289 B -24 B (-8%)
/dist/esm/utils/toSafeId.mjs - 116 B +116 B
/dist/cjs/utils/toSafeId.js - 125 B +125 B

powered by: naverpay size-action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants