fix: move useMemo to top-level to satisfy Hooks order

cgen-53cf3167dec34b459df8de253b49fe1f
This commit is contained in:
Builder.io 2025-09-28 06:36:40 +00:00
parent d0e94523ad
commit bf8e1d65b5

View file

@ -107,6 +107,17 @@ export default function Onboarding() {
const CurrentStepComponent = steps[currentStep].component;
// Precompute decorative particles using useMemo at top-level to avoid hooks in JSX
const particles = useMemo(() => {
if (typeof window === "undefined") return [];
return Array.from({ length: 8 }).map(() => ({
left: `${Math.floor(Math.random() * 100)}%`,
top: `${Math.floor(Math.random() * 100)}%`,
delay: `${Math.random().toFixed(2)}s`,
duration: `${3 + Math.floor(Math.random() * 2)}s`,
}));
}, []);
const finishOnboarding = async () => {
if (!user) {
navigate("/login");