diff --git a/documentation/blog/2024-01-25-react-use-callback.md b/documentation/blog/2024-09-26-react-use-callback.md similarity index 65% rename from documentation/blog/2024-01-25-react-use-callback.md rename to documentation/blog/2024-09-26-react-use-callback.md index 7f30bf579a18..850369d78a85 100644 --- a/documentation/blog/2024-01-25-react-use-callback.md +++ b/documentation/blog/2024-09-26-react-use-callback.md @@ -4,11 +4,11 @@ description: Improve app performance with React useCallback() hook. slug: react-usecallback-guide authors: abdullah_numan tags: [react] -image: https://refine.ams3.cdn.digitaloceanspaces.com/blog/2022-09-20-react-use-callback/social.png +image: https://refine.ams3.cdn.digitaloceanspaces.com/blog/2022-09-20-react-use-callback/social-2.png hide_table_of_contents: false --- -**_This article was last updated on January 25, 2024 to expand code examples add more real use-cases for React useCallback hook._** +**_This article was last updated on January 25, 2024 to include comparisons between useCallback and useMeme and how to use useCallback with other hooks._** ## Introduction @@ -25,14 +25,13 @@ In this post, we explore how to use React `useCallback` in order to memoize a fu Steps we'll cover: +- [Introduction](#introduction) - [What is React `useCallback` ?](#what-is-react-usecallback-) - - [Why Use React `useCallback` Hook?](#why-use-react-usecallback-hook) -- [Memoize Functions with React `useCallback`: Ensuring A Callback's Referential Equality](#memoize-functions-with-react-usecallback-ensuring-a-callbacks-referential-equality) - - [Referential Inequality of Callbacks: Observing Unnecessary Re-renders](#referential-inequality-of-callbacks-observing-unnecessary-re-renders) - - [Memoizing an Event Listener with `useCallback()`](#memoizing-an-event-listener-with-usecallback) - - [React `useCallback` with Dependencies](#react-usecallback-with-dependencies) +- [useCallback vs useMemo](#usecallback-vs-usememo) - [When to Use React `useCallback`](#when-to-use-react-usecallback) - [When Not to Use React's `useCallback` Hook](#when-not-to-use-reacts-usecallback-hook) +- [Bonus:useCallback with Other Hooks](#bonususecallback-with-other-hooks) +- [Example](#example) ## What is React `useCallback` ? @@ -92,7 +91,7 @@ const UserPostsIndex = ({ signedIn }) => { }, []); return ( -
+

Your Posts

{signedIn ? `Signed in` : `Signed out `}

@@ -125,7 +124,7 @@ const UserPostsList = ({ userPosts, deletePost }) => { return (
{userPosts.map((post) => ( -
+