Summary
Following the same pattern introduced for Price (#751), we need to:
- Make
Sku component work standalone (without SkusContainer)
- Deprecate
SkusContainer
- Implement a module-level debounce batch store for automatic request batching
Tasks
1. Shared debounce batch store
Extract the batch store logic introduced in packages/hooks/src/pricesBatchStore.ts into a generic, reusable debounce batch store that can be consumed by any component needing it (e.g. Price, Sku, and future components).
2. packages/hooks
- Refactor
pricesBatchStore.ts to use the new shared batch store
- Add
skusBatchStore.ts using the shared batch store
- Update
useSkus.ts (or equivalent) to subscribe via useSyncExternalStore
3. packages/react-components
- Update
Sku.tsx to detect standalone mode (setSkuCodes == null), register/unregister via the store
- Deprecate
SkusContainer with migration hints (before/after examples)
4. packages/document
- Add standalone
Sku story
- Update
SkusContainer docs with deprecation notice
Deprecation
Before (deprecated):
<SkusContainer>
<Sku />
</SkusContainer>
After (recommended):
All instances are automatically batched into a single API request via the shared debounce store.
References
Summary
Following the same pattern introduced for
Price(#751), we need to:Skucomponent work standalone (withoutSkusContainer)SkusContainerTasks
1. Shared debounce batch store
Extract the batch store logic introduced in
packages/hooks/src/pricesBatchStore.tsinto a generic, reusable debounce batch store that can be consumed by any component needing it (e.g.Price,Sku, and future components).2.
packages/hookspricesBatchStore.tsto use the new shared batch storeskusBatchStore.tsusing the shared batch storeuseSkus.ts(or equivalent) to subscribe viauseSyncExternalStore3.
packages/react-componentsSku.tsxto detect standalone mode (setSkuCodes == null), register/unregister via the storeSkusContainerwith migration hints (before/after examples)4.
packages/documentSkustorySkusContainerdocs with deprecation noticeDeprecation
Before (deprecated):
After (recommended):
All instances are automatically batched into a single API request via the shared debounce store.
References
packages/hooks/src/pricesBatchStore.ts— reference implementation