Skip to content

Instantly share code, notes, and snippets.

@Sergioamjr
Last active May 22, 2021 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sergioamjr/66ab79c34865eab4a6317f47d893bac6 to your computer and use it in GitHub Desktop.
Save Sergioamjr/66ab79c34865eab4a6317f47d893bac6 to your computer and use it in GitHub Desktop.
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