Summary
Refactor HostedCart.tsx to fix bugs and align with the patterns established in CheckoutLink and CartLink.
Changes
- Fix Rules of Hooks violation — move all
useContext calls above the early return null
- Update JSDoc — replace deprecated
<OrderContainer> with <Order>
- Extract duplicated
domain constant — 'commercelayer.io' hardcoded twice
- Fix missing
customDomain — second getApplicationLink call inside useEffect was not forwarding the prop
- Extract shared cart URL resolver — deduplicate
getOrganizationConfig + getApplicationLink logic
- Fix
useEffect dependency anti-pattern — [ref.current != null] is not a valid dep array for iframe resizer setup
- Replace
.then() with async/await in the effect
- Remove commented-out code —
// zIndex lines in default styles
Summary
Refactor
HostedCart.tsxto fix bugs and align with the patterns established inCheckoutLinkandCartLink.Changes
useContextcalls above the earlyreturn null<OrderContainer>with<Order>domainconstant —'commercelayer.io'hardcoded twicecustomDomain— secondgetApplicationLinkcall insideuseEffectwas not forwarding the propgetOrganizationConfig+getApplicationLinklogicuseEffectdependency anti-pattern —[ref.current != null]is not a valid dep array for iframe resizer setup.then()withasync/awaitin the effect// zIndexlines in default styles