Last active
April 23, 2021 12:54
-
-
Save joboccara/eb8af006c22f1c8ff5f7e976da902daa to your computer and use it in GitHub Desktop.
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
const MemoComponent = React.memo(({ onClick }) => { | |
const buttonRef = React.useRef(null); | |
React.useEffect(() => { | |
const buttonDOM = buttonRef.current; | |
buttonDOM.addEventListener("click", onClick); | |
return () => buttonDOM.removeEventListener("click", onClick); | |
}, []); | |
return ( | |
<Button ref={buttonRef}>Click on the memo</button> | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment