mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-25 19:01:38 +01: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]);
|
|
}
|