Now I can see the problem. The useEffect that handles the typewriter effect has a dependency on selectedProducts and topCategory, but these are derived values that get recalculated on every render. When step changes to "result", selectedProducts is computed from selectedProductIds and products -- but the dependency array comparison causes infinite re-renders or the effect never fires properly because selectedProducts is a new array reference each time. Let me also check if there are issues with the currentSection progression logic.
The issues I see:
selectedProducts in the useEffect dependency array is a new array reference each render, potentially causing infinite loops or skipped effectsuseEffect depends on selectedProducts (unstable reference) and topCategory which also re-computes each rendercurrentSection effect should only progress after the typewriter finishes, but they're in separate effectsLet me fix this:
Now update the result step to use analysisProducts and resolvedCategory (the stable snapshots) instead of the derived values:
The fix addresses three root issues: (1) snapshot analysisProducts, resolvedCategory, and introText are now computed once at confirm-time and stored in state, eliminating unstable derived references in effects; (2) the typewriter useEffect now only depends on [strategy, step] so it fires exactly once when results arrive; (3) a typewriterRef properly tracks the interval and cleans it up on reset to prevent stale intervals or memory leaks.
I pulled the latest changes from v0/tugaskuliahlouis-4364-36c35fdc in OptimaBiz-nk.