{"id":32939,"date":"2024-11-01T09:12:37","date_gmt":"2024-11-01T09:12:37","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=32939"},"modified":"2024-11-01T11:21:23","modified_gmt":"2024-11-01T11:21:23","slug":"react-course-optimization-and-memorization","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/32939\/","title":{"rendered":"React Course: Optimization and Memorization"},"content":{"rendered":"<p><body><\/p>\n<p>\n    React is a very popular JavaScript library for building UI. Managing complex applications while using React is not an easy task. In this process, performance optimization and memoization play an important role. This course will explain various techniques and concepts to improve the performance of React applications.\n<\/p>\n<h2>1. Basic Concepts of React<\/h2>\n<p>\n    React has a component-based architecture, where each component independently manages its state and renders the UI. React focuses on improving performance by minimizing actual DOM changes through the Virtual DOM. However, not all components operate efficiently by default, and optimization is necessary.\n<\/p>\n<h2>2. The Need for Performance Optimization<\/h2>\n<p>\n    In complex applications, unnecessary rendering or prolonged data processing can occur. These issues can degrade the user experience, and if optimization is not applied, the application will perform slowly. Therefore, performance optimization becomes an essential part of application development.\n<\/p>\n<h3>2.1. Goals of Optimization<\/h3>\n<ul>\n<li>Improvement of rendering speed<\/li>\n<li>Increased efficiency in state management<\/li>\n<li>Minimization of unnecessary calculations<\/li>\n<\/ul>\n<h2>3. Memoization in React<\/h2>\n<p>\n    Memoization is an optimization technique that stores the results of function calls to avoid redundant calculations for the same input values. Utilizing memoization in React can improve rendering performance. In React, memoization is primarily implemented using <code>React.memo<\/code>, <code>useMemo<\/code>, and <code>useCallback<\/code> hooks.\n<\/p>\n<h3>3.1. React.memo<\/h3>\n<p>\n<code>React.memo<\/code> memoizes a component, preventing re-rendering when the same props are passed. For instance, when a child component does not depend on the parent&#8217;s state, using <code>React.memo<\/code> can reduce unnecessary rendering.\n<\/p>\n<pre><code>const MyComponent = React.memo(({ value }) =&gt; {\n    console.log(\"Rendering: \", value);\n    return &lt;div&gt;{value}&lt;\/div&gt;;\n});<\/code><\/pre>\n<h3>3.2. useMemo<\/h3>\n<p>\nThe <code>useMemo<\/code> hook memoizes the calculation results within a component, preventing repeated calculations as long as the values specified in the dependency array do not change. This allows for the optimization of complex calculations.\n<\/p>\n<pre><code>const memoizedValue = useMemo(() =&gt; {\n    return computeExpensiveValue(a, b);\n}, [a, b]);<\/code><\/pre>\n<h3>3.3. useCallback<\/h3>\n<p>\nThe <code>useCallback<\/code> hook memoizes a function, reusing the previously created function unless the values specified in the dependency array change. This helps to prevent unnecessary rendering in child components.\n<\/p>\n<pre><code>const memoizedCallback = useCallback(() =&gt; {\n    doSomething(a, b);\n}, [a, b]);<\/code><\/pre>\n<h2>4. Additional Tips for React Optimization<\/h2>\n<ul>\n<li><strong>Proper State Management:<\/strong> Depending on the scale of your project, it&#8217;s advisable to use state management libraries like Context API, Recoil, or Redux.<\/li>\n<li><strong>Maintain Immutability:<\/strong> By preserving the immutability of state, you can maximize React&#8217;s optimization capabilities.<\/li>\n<li><strong>Lazy Loading:<\/strong> Load components or resources only when needed to reduce initial rendering time.<\/li>\n<\/ul>\n<h2>5. Practice: Applying Memoization<\/h2>\n<p>\n    After understanding the optimization techniques, let&#8217;s apply memoization to a React application. Here is an example that demonstrates improved performance through memoization.\n<\/p>\n<pre><code>import React, { useState, useMemo } from 'react';\n\nconst ExpensiveComponent = ({ calculate }) =&gt; {\n    const result = useMemo(() =&gt; {\n        return calculate();\n    }, [calculate]);\n\n    return &lt;div&gt;Result: {result}&lt;\/div&gt;;\n};\n\nconst App = () =&gt; {\n    const [count, setCount] = useState(0);\n\n    const calculate = () =&gt; {\n        let total = 0;\n        for (let i = 0; i &lt; 1e6; i++) {\n            total += i;\n        }\n        return total + count;\n    }\n\n    return (\n        &lt;div&gt;\n            &lt;button onClick={() =&gt; setCount(count + 1)}&gt;Increase Count&lt;\/button&gt;\n            &lt;ExpensiveComponent calculate={calculate} \/&gt;\n        &lt;\/div&gt;\n    );\n};\n\nexport default App;<\/code><\/pre>\n<h2>6. Conclusion<\/h2>\n<p>\n    Optimization and memoization in React applications are important factors in providing efficient performance. By utilizing React.memo, useMemo, and useCallback, you can reduce unnecessary rendering and calculations, thereby enhancing the user experience. Apply the concepts you&#8217;ve learned from this course to achieve performance optimization in your projects.\n<\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>React is a very popular JavaScript library for building UI. Managing complex applications while using React is not an easy task. In this process, performance optimization and memoization play an important role. This course will explain various techniques and concepts to improve the performance of React applications. 1. Basic Concepts of React React has a &hellip; <a href=\"https:\/\/atmokpo.com\/w\/32939\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;React Course: Optimization and Memorization&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[123],"tags":[],"class_list":["post-32939","post","type-post","status-publish","format-standard","hentry","category-react-basics-course"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>React Course: Optimization and Memorization - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/atmokpo.com\/w\/32939\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"React Course: Optimization and Memorization - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"React is a very popular JavaScript library for building UI. Managing complex applications while using React is not an easy task. In this process, performance optimization and memoization play an important role. This course will explain various techniques and concepts to improve the performance of React applications. 1. Basic Concepts of React React has a &hellip; \ub354 \ubcf4\uae30 &quot;React Course: Optimization and Memorization&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/32939\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:12:37+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:21:23+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"3\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/32939\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32939\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"React Course: Optimization and Memorization\",\"datePublished\":\"2024-11-01T09:12:37+00:00\",\"dateModified\":\"2024-11-01T11:21:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32939\/\"},\"wordCount\":427,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"React basics course\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/32939\/\",\"url\":\"https:\/\/atmokpo.com\/w\/32939\/\",\"name\":\"React Course: Optimization and Memorization - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:12:37+00:00\",\"dateModified\":\"2024-11-01T11:21:23+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32939\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/32939\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/32939\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"React Course: Optimization and Memorization\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"React Course: Optimization and Memorization - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/atmokpo.com\/w\/32939\/","og_locale":"ko_KR","og_type":"article","og_title":"React Course: Optimization and Memorization - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"React is a very popular JavaScript library for building UI. Managing complex applications while using React is not an easy task. In this process, performance optimization and memoization play an important role. This course will explain various techniques and concepts to improve the performance of React applications. 1. Basic Concepts of React React has a &hellip; \ub354 \ubcf4\uae30 \"React Course: Optimization and Memorization\"","og_url":"https:\/\/atmokpo.com\/w\/32939\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:12:37+00:00","article_modified_time":"2024-11-01T11:21:23+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"3\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/32939\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/32939\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"React Course: Optimization and Memorization","datePublished":"2024-11-01T09:12:37+00:00","dateModified":"2024-11-01T11:21:23+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/32939\/"},"wordCount":427,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["React basics course"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/32939\/","url":"https:\/\/atmokpo.com\/w\/32939\/","name":"React Course: Optimization and Memorization - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:12:37+00:00","dateModified":"2024-11-01T11:21:23+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/32939\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/32939\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/32939\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"React Course: Optimization and Memorization"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32939","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=32939"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32939\/revisions"}],"predecessor-version":[{"id":32940,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32939\/revisions\/32940"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=32939"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=32939"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=32939"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}