Arka S.’s Post

If removing every useMemo and useCallback from your app changes nothing… They were never fixing the problem. 😭 We’ve all done it. App feels slow → immediately add: useMemo(...) useCallback(...) Suddenly we feel like we’ve optimized the app. 🤡 Meanwhile the real problem is still there: • Rendering 5,000 rows • Fetching 2MB of JSON • Re-rendering the whole page • 14 charts fighting for their lives useMemo and useCallback are useful — but only when they solve an actual bottleneck. If deleting them makes no noticeable difference, they were probably just performance-flavored decoration. And since memoization is not free, you may have actually made things slightly slower. 💀 One exception: If a function is passed as a dependency, useCallback can keep the reference stable. But if the function is only used inside the effect, just move it into the effect: // ❌ Unnecessary const fetchData = useCallback(() => fetch('/api/data'), []); useEffect(() => { fetchData(); }, [fetchData]); // ✅ Simpler useEffect(() => { const fetchData = () => fetch('/api/data'); fetchData(); }, []); Most React apps are not slow because of this: onClick={() => setOpen(true)} They are slow because somewhere deep in the codebase there is a component rendering the entire internet on every keystroke. 😭 React’s advice is simple: Profile first. Then optimize. Otherwise you are just making the code harder to read for free. We didn’t optimize the app. We put Flex Tape on a waterfall. 🌊 #ReactJS #JavaScript #WebDev #Frontend #ReactHooks #FrontendDevelopment #SoftwareEngineering #DevHumor #CodeNewbie #100DaysOfCode

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories