Files
yaak-mountain-loop/apps/yaak-client/hooks/useScrollIntoView.ts
2026-05-07 15:50:10 -07:00

10 lines
249 B
TypeScript

import { useEffect } from "react";
export function useScrollIntoView<T extends HTMLElement>(node: T | null, enabled: boolean) {
useEffect(() => {
if (enabled) {
node?.scrollIntoView({ block: "nearest" });
}
}, [enabled, node]);
}