Created
March 8, 2022 20:48
-
-
Save Cogentx/81112f864522db5b880b67c8c9996b26 to your computer and use it in GitHub Desktop.
React TypeScript useRef Type Definitions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// It's important to pass NULL as the default value to useRef Hook since React.useRef can only be NULL or an Element Object. | |
// <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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment