feat: url navigation for settings (#821)

This commit is contained in:
Carlos Valente
2024-03-18 20:36:02 +01:00
committed by GitHub
parent 4b21745fc7
commit dfade25a7c
11 changed files with 147 additions and 61 deletions
@@ -0,0 +1,15 @@
import { useEffect, useRef } from 'react';
export default function useScrollIntoView<T extends HTMLElement>(name: string, location?: string) {
const ref = useRef<T>(null);
useEffect(() => {
if (location && ref.current) {
if (location === name) {
ref.current.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
}
}, [location, name]);
return ref;
}