mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 23:16:21 +00:00
6bf3366af7
React reported "Rendered more hooks than during the previous render" when CatalogPurchaseWidgetView transitioned from currentOffer=null to a real offer: hook count jumped from 22 to 23 because the useMemo/useEffect block for the builders-club placement state sat *below* the `if(!currentOffer) return null` early-return on line 140. On the first render it never ran; on the next render (offer loaded) it did, and React's hook-call tracker flagged the divergence and unmounted the component via the error boundary. Fix: move the three builders-club hooks (useMemo builderPlaceableStatus, useMemo buildersClubPlaceOneButtonStyle, useEffect interval) above the early return. They already short-circuit cleanly when isBuildersClubPlaceable is false — added a defensive `!currentOffer` guard on the first useMemo and an explicit `!!currentOffer` clause on the derived isBuildersClubPlaceable so the .product access stays safe when offer is null. Behavior unchanged for the loaded-offer path; the early-render path now runs the hooks but their bodies no-op. Verification: yarn typecheck clean, yarn test 209/209.