diff --git a/apps/laboratory/src/components/RandomLink.tsx b/apps/laboratory/src/components/RandomLink.tsx index 37dbcae0cb..d95247a047 100644 --- a/apps/laboratory/src/components/RandomLink.tsx +++ b/apps/laboratory/src/components/RandomLink.tsx @@ -3,11 +3,19 @@ import Link from 'next/link' import { useState, useEffect } from 'react' -export function RandomLink({ hrefs, children }: { hrefs: string[]; children: React.ReactNode }) { +export function RandomLink({ + hrefs = [], + children +}: { + hrefs: string[] + children: React.ReactNode +}) { const [href, setHref] = useState() useEffect(() => { const newHref = hrefs[Math.floor(Math.random() * hrefs.length)] - setHref(newHref) + if (newHref) { + setHref(newHref) + } }, [hrefs]) return href ? {children} : <>