{"id":2020,"date":"2025-04-20T23:30:59","date_gmt":"2025-04-20T15:30:59","guid":{"rendered":"https:\/\/www.tonghin.com.my\/blog\/?p=2020"},"modified":"2025-04-20T23:31:00","modified_gmt":"2025-04-20T15:31:00","slug":"enhancing-ui-performance-and-auto-refresh-implementation","status":"publish","type":"post","link":"https:\/\/www.tonghin.com.my\/blog\/2025\/04\/20\/enhancing-ui-performance-and-auto-refresh-implementation\/","title":{"rendered":"Enhancing UI Performance and Auto-Refresh Implementation"},"content":{"rendered":"\n<p>Monday, March 24 2025 \u2013Last week, I focused on resolving several UI bugs based on the latest findings. While addressing these issues, I also identified and implemented necessary improvements.<\/p>\n\n\n\n<p>The first task was to create a new dropdown component that displays a list of all stores. This dropdown was required for features that had recently been developed, making it essential to have a reusable component for consistency.<\/p>\n\n\n\n<p>Next, I worked on implementing an auto-refresh mechanism that updates the page every five seconds. Using useEffect, the function runs at a set interval (which I set to 10 seconds) but only when the page is visible. It detects when the tab is active, triggering the function immediately and then setting up a timer to refresh the data. If the tab is hidden, the timer stops to conserve resources.&nbsp;<\/p>\n\n\n\n<p>Initially, I applied this feature to all pages that retrieved lists of data. However, Mr. Peter later advised that it should only be implemented on specific lists, prompting me to refactor the logic into a reusable component. I placed this component under the hooks folder and tested it on the selected lists. The component automatically runs when the tab is active, executing a callback function passed from the parent page. The callback was defined as void, simply acting as a trigger.<\/p>\n\n\n\n<p>By the end of the week, the component successfully refreshed the page as intended. However, there was one issue, filters and pagination reset to their initial state upon refresh. This occurred because the component\u2019s useEffect reloaded the content, causing state loss. Resolving this behavior will be the next step in refining the implementation.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Monday, March 24 2025 \u2013Last week, I focused on resolving several UI bugs based on the latest findings. While addressing these issues, I also identified and implemented necessary improvements. The first task was to create a new dropdown component that displays a list of all stores. This dropdown was required for features that had recently &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.tonghin.com.my\/blog\/2025\/04\/20\/enhancing-ui-performance-and-auto-refresh-implementation\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Enhancing UI Performance and Auto-Refresh Implementation&#8221;<\/span><\/a><\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v15.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Enhancing UI Performance and Auto-Refresh Implementation | Tong Hin&#039;s Blog<\/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:\/\/www.tonghin.com.my\/blog\/2025\/04\/20\/enhancing-ui-performance-and-auto-refresh-implementation\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Enhancing UI Performance and Auto-Refresh Implementation | Tong Hin&#039;s Blog\" \/>\n<meta property=\"og:description\" content=\"Monday, March 24 2025 \u2013Last week, I focused on resolving several UI bugs based on the latest findings. While addressing these issues, I also identified and implemented necessary improvements. The first task was to create a new dropdown component that displays a list of all stores. This dropdown was required for features that had recently &hellip; Continue reading &quot;Enhancing UI Performance and Auto-Refresh Implementation&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.tonghin.com.my\/blog\/2025\/04\/20\/enhancing-ui-performance-and-auto-refresh-implementation\/\" \/>\n<meta property=\"og:site_name\" content=\"Tong Hin&#039;s Blog\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-20T15:30:59+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-04-20T15:31:00+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"2 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#organization\",\"name\":\"TONG HIN MACHINERY\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"sameAs\":[\"https:\/\/www.youtube.com\/channel\/UC60EoxJMNbu8mV0LuEGfrBg\"],\"logo\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#logo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/wp-content\/uploads\/2020\/10\/web_logo_180_180.jpg\",\"width\":180,\"height\":180,\"caption\":\"TONG HIN MACHINERY\"},\"image\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#logo\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#website\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"name\":\"Tong Hin&#039;s Blog\",\"description\":\"Sharing About Technology\",\"publisher\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/www.tonghin.com.my\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2025\/04\/20\/enhancing-ui-performance-and-auto-refresh-implementation\/#webpage\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/2025\/04\/20\/enhancing-ui-performance-and-auto-refresh-implementation\/\",\"name\":\"Enhancing UI Performance and Auto-Refresh Implementation | Tong Hin&#039;s Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#website\"},\"datePublished\":\"2025-04-20T15:30:59+00:00\",\"dateModified\":\"2025-04-20T15:31:00+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2025\/04\/20\/enhancing-ui-performance-and-auto-refresh-implementation\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.tonghin.com.my\/blog\/2025\/04\/20\/enhancing-ui-performance-and-auto-refresh-implementation\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2025\/04\/20\/enhancing-ui-performance-and-auto-refresh-implementation\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2025\/04\/20\/enhancing-ui-performance-and-auto-refresh-implementation\/\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/2025\/04\/20\/enhancing-ui-performance-and-auto-refresh-implementation\/\",\"name\":\"Enhancing UI Performance and Auto-Refresh Implementation\"}}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2025\/04\/20\/enhancing-ui-performance-and-auto-refresh-implementation\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2025\/04\/20\/enhancing-ui-performance-and-auto-refresh-implementation\/#webpage\"},\"author\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#\/schema\/person\/81e2366362d8d14b15519395755cee6f\"},\"headline\":\"Enhancing UI Performance and Auto-Refresh Implementation\",\"datePublished\":\"2025-04-20T15:30:59+00:00\",\"dateModified\":\"2025-04-20T15:31:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2025\/04\/20\/enhancing-ui-performance-and-auto-refresh-implementation\/#webpage\"},\"publisher\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#organization\"},\"articleSection\":\"Experiential\",\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#\/schema\/person\/81e2366362d8d14b15519395755cee6f\",\"name\":\"nurlailiyuzi\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/5c0d4cc6f7fc881bd56d95bdbb0c4c14?s=96&d=mm&r=g\",\"caption\":\"nurlailiyuzi\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts\/2020"}],"collection":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/comments?post=2020"}],"version-history":[{"count":2,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts\/2020\/revisions"}],"predecessor-version":[{"id":2022,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts\/2020\/revisions\/2022"}],"wp:attachment":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/media?parent=2020"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/categories?post=2020"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/tags?post=2020"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}