Rohan kumar’s Post

React 18/19 solves this with useDeferredValue. Stop using setTimeout to debounce your search inputs For years, whenever we built a real-time search feature, we reached for Lodash or wrote a custom setTimeout hook: “Wait 300ms after the user stops typing,then run the search.” It worked but it also introduced input latency. The user types, and the app intentionally waits. It feels sluggish. ❌ The Old Way (Debouncing – Time-Based) You force every user to wait. On a fast device → they still wait 300ms. On a slow device → the timer may fire while they’re still typing, causing UI freezes. It’s artificial delay. ✅ The Modern Way (Deferring – Priority-Based) React splits the update into two priorities: Urgent: → Update the input field instantly (immediate feedback). Deferred: → Update the search results in the background. React renders the results as fast as the device allows: ⚡ Fast device → Updates almost instantly (0ms delay) 🐢 Slow device → Updates when the CPU is free 🔄 Interruptible → If the user types again, React cancels the old render and starts the new one No fixed delays. No guessing. No hacks. 🚀 The Shift We’re moving from time-based optimization to priority-based optimization. That’s a big mindset change. #ReactJS #WebDevelopment #Frontend #JavaScript #Performance #CleanCode #TechTips #React #Tips #ReactTips #DeveloperTips

what about api call on every key stroke? or it just call api on after typing finish?

Like
Reply

To view or add a comment, sign in

Explore content categories