Skip to content

Instantly share code, notes, and snippets.

@ryardley
Last active March 3, 2019 04:53
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 ryardley/17a226972ec140306165b5758bbf92b9 to your computer and use it in GitHub Desktop.
Save ryardley/17a226972ec140306165b5758bbf92b9 to your computer and use it in GitHub Desktop.
Creating new handlers every render can cause performance problems.
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