const inputRef = React.useRef<HTMLInputElement | null>(null);
import { useRef, useLayoutEffect } from "react";
//HTMLInputElement || define the type of element
const element = useRef<HTMLInputElement>(null);
useLayoutEffect(() => {
//object can be null
if (element.current !== null) {
element.current.focus();
}
});
// <div> reference type
const divRef = React.useRef<HTMLDivElement>(null);
// <button> reference type
const buttonRef = React.useRef<HTMLButtonElement>(null);
// <br /> reference type
const brRef = React.useRef<HTMLBRElement>(null);
// <a> reference type
const linkRef = React.useRef<HTMLLinkElement>(null);
// create refernce for element
let refName= useState<HTMLDivElement>(null)
//usage
<div ref={refName} className=""></div>
// access in useEffect
refName.current
const iconRef = useRef<HTMLDivElement>(null!);
const [headerValue, setHeaderValue] = useState<number>(1);