mirror of
https://github.com/deiucanta/chatpad.git
synced 2026-03-11 09:04:31 +00:00
16 lines
358 B
TypeScript
16 lines
358 B
TypeScript
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 (
|
|
<div ref={myRef}>
|
|
{children}
|
|
</div>
|
|
);
|
|
}
|