How to use React useRef with TypeScript

PHOTO EMBED

Thu Sep 16 2021 06:55:50 GMT+0000 (Coordinated Universal Time)

Saved by @chillymood #javascript

// <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);
content_copyCOPY

https://linguinecode.com/post/how-to-use-react-useref-with-typescript