diff --git a/src/components/ScrollIntoView.tsx b/src/components/ScrollIntoView.tsx index 39a5718..eaf3a47 100644 --- a/src/components/ScrollIntoView.tsx +++ b/src/components/ScrollIntoView.tsx @@ -1,13 +1,15 @@ -import { ReactNode } from "react"; +import { ReactNode, useRef, useEffect } from "react"; export function ScrollIntoView({ children }: { children: ReactNode }) { + + // Scroll into view as soon as we appear + const myRef = useRef(null); + useEffect(() => { + myRef.current.scrollIntoView({ behavior: 'smooth' }); + }, []); + return ( -
{ - if (!node) return; - node.scrollIntoView({ behavior: "smooth" }); - }} - > +
{children}
);