Confetti does not fire when registration opens on page load #5
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug
Confetti never plays for users who visit the site after registration has already opened.
Root cause
The confetti logic lives in
CountdownBanner(apps/web/src/components/homepage/CountdownBanner.tsx):This
useEffectonly fires whenisOpentransitions fromfalsetotrue(i.e. the dependency array changes). When a user opens the page afterREGISTRATION_OPENS_AThas already passed,useRegistrationOpen()returnsisOpen: trueon the very first render. React never sees afalse → truechange, so the effect never fires.On top of that,
EventRegistrationFormskips rendering<CountdownBanner>entirely whenisOpenis alreadytrue, so the component never even mounts.The confetti only works for users who had the page open before the registration timer hit zero.
Fix
Move the confetti logic out of
CountdownBannerand intoEventRegistrationForm, where it can fire on first mount whenisOpenis alreadytrue, as well as on the livefalse → truetransition.Because
EventRegistrationFormis always mounted (it renders either the countdown or the real form), itsuseEffectruns on mount regardless of whetherisOpenstarts astrueor flips later. TheconfettiFiredref still ensures it fires exactly once per session.The
fireConfettifunction and theconfettiFiredref can then be removed fromCountdownBanner.