Last active
March 3, 2019 04:53
-
-
Save ryardley/17a226972ec140306165b5758bbf92b9 to your computer and use it in GitHub Desktop.
Creating new handlers every render can cause performance problems.
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
function App() { | |
const [count, setCount] = useState(0); | |
// handler will be created on every render | |
const handleClick = () => { | |
setCount(count + 1); | |
}; | |
return ( | |
<SomePureComponent count={count} onClick={handleClick} /> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment