mirror of
https://github.com/mountain-loop/yaak.git
synced 2025-12-23 22:48:55 -05:00
10 lines
249 B
TypeScript
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]);
|
|
}
|