React performance isn't about adding useMemo everywhere. 🚫 It's about measuring first — then fixing the right thing. Most engineers optimize by intuition. They add useMemo, split bundles, wrap everything in memo — and the app is now more complex but no faster. Because they fixed the wrong thing. There are exactly three categories of React performance problems: 1. Too much JavaScript Bundle too large → slow initial load → high Time to Interactive Fix: code splitting, React.lazy, dynamic imports 2. Too much rendering Components re-rendering unnecessarily → laggy interactions Fix: React.memo, useMemo, useCallback — but only where justified 3. Too much browser work Layout thrashing, no virtualisation → dropped frames, janky scroll Fix: separate DOM reads from writes, react-window for long lists The fix for one category can actively make another worse if applied blindly. Wrapping everything in useMemo adds comparison overhead on every render. Splitting every bundle into tiny chunks creates more network requests. Optimizing the wrong category = more complexity, zero gain. The process that actually works: Reproduce → Measure → Identify the category → Fix that specific thing → Measure again. Chrome DevTools Performance tab tells you where the browser is struggling. React DevTools Profiler tells you which components are the problem. Two different tools. Two different questions. Know which one to reach for. One thing that surprised me — layout thrashing is almost invisible until you know what to look for. Reading offsetHeight and writing style, height in the same loop forces the browser to recalculate layout on every single iteration. Separating all reads from all writes drops it to one calculation. Same code. Completely different performance. Small things. Large consequences at scale. Sharing one deep dive at a time. #React #WebPerformance #FrontendEngineering #JavaScript #PlatformEngineering
React Performance: Measure, Identify, Fix
More Relevant Posts
-
Your component is re-rendered... Then what? Most developers stop thinking here. And that’s where the real magic starts. This is Post 3 of the series: 𝗥𝗲𝗮𝗰𝘁 𝗨𝗻𝗱𝗲𝗿 𝘁𝗵𝗲 𝗛𝗼𝗼𝗱 Where I explain what React is actually doing behind the scenes. React does NOT update the DOM immediately. Because touching the DOM is expensive. Instead, it follows a 3-step process: Render → Diff → Commit First, React creates something called a 𝗩𝗶𝗿𝘁𝘂𝗮𝗹 𝗗𝗢𝗠. Not the real DOM. Just a JavaScript object in memory. A blueprint of your UI. Every time your component runs, React builds a new tree of this Virtual DOM. And it already has the previous tree stored. Now comes the interesting part. React compares: Old tree vs New tree This step is called 𝗗𝗶𝗳𝗳𝗶𝗻𝗴. It finds exactly what changed. Not everything. Just the difference. Then comes the final step: 𝗖𝗼𝗺𝗺𝗶𝘁 phase React takes only those changes… …and updates the real browser DOM So no, React is NOT re-rendering your whole page. It’s doing surgical updates. The key insight: React separates thinking from doing. Thinking = Render + Diff Doing = Commit That’s why React is fast. Because touching the DOM is expensive. So React minimizes it. Flow looks like this: ✅️ Component runs ✅️ Virtual DOM created ✅️ Changes calculated ✅️ DOM updated ✅️ Browser paints UI Once you see this, you stop fearing re-renders. And start understanding them. In Post 4 of React Under the Hood: How does React actually compare trees? (The diffing algorithm 👀) Follow Farhaan Shaikh if you want to understand react more deeply. 👉 Read in detail here: https://lnkd.in/dTYAbM6n #React #Frontend #WebDevelopment #JavaScript #SoftwareEngineering
To view or add a comment, sign in
-
A small JavaScript concept that has a big impact on performance: Debouncing When a user types into a search input, every keystroke can trigger a function. Without debounce: H He Hel Hell Hello That can mean multiple API calls for a single final search. Debouncing solves this by delaying execution until the user pauses. Result: • fewer requests • lower backend load • reduced unnecessary processing • better user experience What looks like a frontend optimization actually affects backend efficiency too. Good engineering often starts with deciding when not to execute. #JavaScript #BackendEngineering #Performance #WebDevelopment #SystemDesign
To view or add a comment, sign in
-
where does that 'e' or 'event' come from?? If you have ever wondered why that object magically appears in your 'onClick' handler, the answer lies in how React coordinates the bridge between the browser and your code. It isn't just a standard browser event. It is a very specific system designed to keep your UI consistent. When you pass a function reference like 'onClick={handleClick}', React automatically injects a SyntheticEvent as the first argument. You do not have to do anything. It is just there. This is a cross-browser wrapper that ensures your event logic works the same in every environment. Under the hood, React is doing the heavy lifting of mapping native DOM events to this consistent interface. The behavior changes slightly when you use arrow functions in your JSX. If you write 'onClick={() => handleClick()}', you lose that automatic injection. In this case, you are responsible for capturing the event from the anonymous wrapper and passing it down manually, like 'onClick={(e) => handleClick(e)}'. It is a small syntactic difference, but forgetting this is a common reason why 'event.target' suddenly comes back as undefined. Understanding this flow is crucial for writing clean code. Since React 17 removed event pooling, you no longer have to worry about the event object being nullified after the handler runs. You can now use the event inside asynchronous code without calling 'e.persist()'. It is a simpler and cleaner model that allows you to focus on logic rather than browser quirks. #ReactJS #SoftwareEngineering #WebDevelopment #Javascript #CodingTips #Frontend
To view or add a comment, sign in
-
I wrote the same component 3 times before I realised I only needed to write it once. Days 43–45/100 — 3 days deep into React, and the foundations are finally locking in. Here's everything that clicked this week: 🔹 Fragments — the invisible wrapper React needs a single parent element. But wrapping everything in a <div> pollutes your DOM. <> </> groups your JSX with zero DOM footprint. Clean markup. No ghost divs. No unexpected CSS side effects. 🔹 Map method — lists without the pain In vanilla JS, rendering a list meant loops + manual DOM updates. In React — one .map() call and every item in your array becomes a component. Dynamic. Clean. Automatic. 🔹 Conditional Rendering — 3 tools, 1 goal Making React show the right thing at the right time: • if-else — for complex logic outside JSX • Ternary — clean inline decisions inside JSX • Logical && — show something only when a condition is true Your UI should respond to data — not just display it. 🔹 Passing data via Props Props are how components talk to each other. Parent has data → passes it down → child receives and uses it. Without props, every component is an island. With props, they become a system. 🔹 Destructuring Props Instead of props.name, props.age, props.email everywhere — const { name, age, email } = props. Cleaner. Less repetitive. Readable at a glance. The biggest realisation from these 3 days? A component isn't a fixed UI block. It's a template. Props are the variables. Conditions are the logic. Map is the engine. That's the foundation of almost every React app in production. Day 45 done. 55 to go. 🚀 #100DaysOfCode #ReactJS #MERNStack #WebDevelopment #LearningInPublic #JavaScript #BuildInPublic
To view or add a comment, sign in
-
Why does your page refresh the moment you hit submit? It is the browser's old-school behavior. In the pre-SPA era, browsers were designed to reload and send data to a server after a form submission. But in React, we handle that logic ourselves using state and APIs. This is where 'event.preventDefault()' comes in. By calling it in your 'onSubmit' handler, you tell the browser to stop that default reload. It allows your JavaScript to process the data, show a loading spinner, or update the UI without the user ever losing their place. It is the key to keeping your application feeling like a fast, seamless experience. It is not just for forms. You might use it on anchor tags to stop navigation when a link acts as a button, or on 'onContextMenu' to replace the standard right-click menu with a custom one. It is all about taking full ownership of the user experience and ensuring the browser doesn't step on your toes. #ReactJS #WebDevelopment #SoftwareEngineering #Javascript #Frontend #CodingTips
To view or add a comment, sign in
-
🔥 React DevTools: Common Issues & How to Use It Effectively React DevTools is one of the most powerful tools for diagnosing performance issues… but many developers don’t use it correctly. Here’s what I’ve learned 👇 ------------------------------------- 🔍 Common Issues Developers Face: 1️⃣ Not Profiling – Many just inspect components without measuring re-renders or performance. 2️⃣ Ignoring Component Trees – Deep trees hide unnecessary renders. 3️⃣ Overlooking State & Props – Changes in parent state can trigger unexpected child re-renders. 4️⃣ Misreading Flame Charts – Not understanding which operations are expensive. 💡 How to Use React DevTools Effectively: ------------------------------------------------- ✅ Profiler Tab – Measure every render and find bottlenecks. ✅ Highlight Updates – See exactly which components re-render. ✅ Inspect Component Props & State – Check if changes are causing unnecessary renders. ✅ Compare Commits – Analyze how updates affect your tree. ✅ Filter and Focus – Only measure the components that matter. 🚀 Pro Tip: “React DevTools doesn’t just show problems… it tells you exactly where to optimize.” 💬 Your Turn: Which feature of React DevTools helped you most in improving performance? #reactjs #reactdeveloper #webdevelopment #frontend #javascript #reactperformance #profiling #devtools #softwareengineering #frontendengineering #performanceoptimization #cleancode #techlead
To view or add a comment, sign in
-
-
🚀 Day 12/30 – Conditional Rendering in React Building dynamic UIs based on conditions ⚡ Today’s focus was on Conditional Rendering — a core concept that makes React apps interactive and user-driven. 🔍 What I learned: ✅ Conditional Rendering allows UI to change based on state ✅ React relies on pure JavaScript logic (if, ternary, &&) inside JSX ✅ Essential for real-world features like authentication, loaders, and error handling 💻 Example: function App() { const isLoggedIn = true; return ( <> {isLoggedIn ? <h1>Welcome User</h1> : <h1>Please Login</h1>} </> ); } 🔥 Common Patterns: 1️⃣ Ternary Operator (Most Used) {condition ? <A /> : <B />} 2️⃣ Logical AND (&&) {isLoggedIn && <Dashboard />} 3️⃣ If Statement (Outside JSX) if (!user) return <Login />; 💡 Real-World Use Cases: ✔️ Showing a loader while fetching data ✔️ Displaying error messages ✔️ Rendering dashboard after login ⚡ Advanced Insight: React doesn’t introduce new syntax for conditions — it simply leverages JavaScript inside JSX, making it flexible and powerful. 🔑 Key Takeaway: 👉 Conditional Rendering = Controlling what users see based on application state. 💬 Curious — which approach do you use more: ternary or if/else logic? #React #FrontendDevelopment #JavaScript #WebDevelopment #LearningInPublic
To view or add a comment, sign in
-
-
🧠 Why map() in React Needs a key (Beyond Just a Warning) Most developers know this warning: “Each child in a list should have a unique key” So they do this 👇 {items.map((item, index) => ( <li key={index}>{item}</li> ))} Warning gone ✅ Problem solved ❌ 🔍 What actually happens? React uses key to track elements between renders. If you use index: 👉 React assumes position = identity ⚠️ The hidden bug const items = ["A", "B", "C"]; Now remove "A". New list: ["B", "C"] With index as key: "B" becomes index 0 React thinks it’s still "A" 👉 UI can behave incorrectly 👉 State can get mixed up ✅ Correct approach {items.map(item => ( <li key={item.id}>{item.name}</li> ))} 👉 Use a stable, unique key 🎯 Real Insight key is not for React warnings. It’s for correct UI behavior. 💥 Senior-level understanding Bad keys don’t always break immediately. They break when: Items reorder Items are removed State is attached to elements That’s why bugs feel random. #ReactJS #FrontendDevelopment #JavaScript #CleanCode #WebDevelopment #CodingTips #LearningInPublic
To view or add a comment, sign in
-
How React 19 Killed My useEffect Fetching Bugs . . I spent 5 hours debugging a "flicker" that didn't exist. My React application's profile page was showing the previous user’s data for a few second on every page load. For years, I treated useEffect as the standard way to fetch data. But useEffect is an escape hatch, not a data-fetching tool. In React 18+, the race conditions became even harder to track. React 19’s use() hook finally makes data fetching declarative. Instead of "syncing" a fetch to a state variable after the component renders, you now await the promise directly inside the component body. This simple change fixed a major race condition issue that was making me scratch my head every time. Is your team still defaulting to useEffect for data, or have you moved to use() / React Query? The "flicker" is a choice now. I have written a detailed breakdown in my Medium article. [Link to article in first comment] #javascript #typescript #react #web
To view or add a comment, sign in
-
-
𝐖𝐡𝐚𝐭 𝐢𝐟 𝐦𝐞𝐚𝐬𝐮𝐫𝐢𝐧𝐠 𝐭𝐞𝐱𝐭 𝐨𝐧 𝐚 𝐰𝐞𝐛𝐩𝐚𝐠𝐞 𝐰𝐚𝐬 500𝐱 𝐟𝐚𝐬𝐭𝐞𝐫? That's not a marketing claim. That's Pretext.js. Every time a browser figures out how tall a block of text is, it stops and re-renders. Do that 1,000 times? Your page crawls. Pretext.js just does the math instead. No tricks. Just arithmetic. Two functions. That's the whole API. → prepare() — describe your text once. → layout() — get the height instantly, every time after. 📊 The numbers are wild: → Traditional DOM approach: 1,000 items = ~94ms → Pretext.js: 1,000 items = ~0.05ms That's 500x faster. Zero DOM access. Built by Cheng Lou (ex-React core team). Already at 39k+ GitHub stars. If you care about fast, smooth web experiences — worth 5 minutes 👉 pretextjs.dev #javascript #webdev #frontend #opensource
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development