Last active
May 22, 2021 16:58
-
-
Save Sergioamjr/66ab79c34865eab4a6317f47d893bac6 to your computer and use it in GitHub Desktop.
This file contains 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
import { useRef, useEffect } from "react"; | |
export default function Component() { | |
const textRef = useRef(null); | |
useEffect(() => { | |
// Get element width | |
console.log(textRef.current.offsetWidth); | |
}, []) | |
return <p ref={textRef}>Exemplo com botão</p>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment