mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-02-24 00:24:54 +01:00
10 lines
266 B
TypeScript
10 lines
266 B
TypeScript
import { useEffect } from 'react';
|
|
|
|
export function useScrollIntoView<T extends HTMLElement>(node: T | null, active: boolean) {
|
|
useEffect(() => {
|
|
if (active) {
|
|
node?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
}
|
|
}, [active, node]);
|
|
}
|