Files
yaak-mountain-loop/apps/yaak-client/hooks/useScrollIntoView.ts
2026-03-06 09:23:19 -08: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]);
}