Skip to content

Instantly share code, notes, and snippets.

@sifat009
Created March 3, 2024 11:43
Show Gist options
  • Save sifat009/5dfe8aa2014ad6f9a7a1190298ef771b to your computer and use it in GitHub Desktop.
Save sifat009/5dfe8aa2014ad6f9a7a1190298ef771b to your computer and use it in GitHub Desktop.
useMemo the right way
/**
* ✅ Topic: Unnecessary useMemo() on props 🧐
* 📨 For training contact: sifathaque6@gmail.com 💬
*/
const ChildrenMemo = React.memo(Children)
const Parent = () => {
const value = useMemo(() => ({value}));
return <ChildrenMemo value={value} /> // ✅ Memoized value will prevent re-render
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment