refactor(hooks): extract composition store from useIsComposing#2716
Open
refactor(hooks): extract composition store from useIsComposing#2716
Conversation
useIsComposing 内にあった capture/bubble それぞれの Map ベースのストアを独立モジュール (utils/compositionStore) に切り出し、フックは `useSyncExternalStore` でストアを選ぶだけの薄いレイヤーに整理した。ストアは React 非依存になりユニットテストが書きやすく、購読切れ目で composing が漏れない挙動 (Bug A) も契約として明示的に保証される。 あわせてテストを describe ブロックで階層化し、store と重複する観点を削除して整理。Storybook はキャプチャ/バブルの発火順を目視確認できるデモに刷新。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
useIsComposing内にあった capture/bubble 用の Map ベースのストアをutils/compositionStoreに切り出し、フック本体はuseSyncExternalStoreでストアを選ぶだけの薄い層に整理composingフラグをリセットする挙動(購読者不在中にcompositionendを取りこぼしても次回マウント時にtrueを引きずらない)を契約として明示化し、回帰テストを追加describeで階層化(基本動作 / ストア選択 / 購読ライフサイクル / 実ユースケース)。store と重複する観点を削除し、captureパラメトライズはit.for、StrictMode 下のリスナーリークチェック、子要素からのbubbles:true経路、composing中 unmount → 再 mount の回帰テストを追加Test plan
pnpm vitest run src/hooks/useIsComposing— 40 件グリーンpnpm check— lint / fmt / knip パス🤖 Generated with Claude Code