What happens actually when you call setState() (Reconciliation phases) 1. Render phase: - React creates Virtual DOM - Compares it with previous one - Decides what needs to change - No real DOM updates here 2. Commit phase: - React applies the changes to real DOM. - Runs lifecycle methods and hooks like: useLayoutEffect 3. Commit phase (Final step): - Runs side effects: useEffects: - Cleanup of previous effects Understanding reconciliation helps you write better, performance-friendly components. #frontend #reactjs #javascript
React setState reconciliation phases explained
More Relevant Posts
-
Closures in JavaScript — Explained Simply A lot of people use closures without actually understanding them. So let’s kill the confusion. What’s a Closure? A closure is just a function that remembers the variables from where it was created, even after that outer function has finished running. Think of it like this The inner function carries a backpack Inside that backpack → variables from the outer scope. #JavaScript #Closures #WebDevelopment #Frontend #ReactJS #LearningInPublic #JavaScriptBasics
To view or add a comment, sign in
-
-
Pros & Cons of useEffect in React ⚛️ ✅ Pros Great for handling side effects like API calls, subscriptions, and timers Replaces class lifecycle methods with much cleaner logic Dependency array gives control over when the effect runs Cleanup functions help prevent memory leaks ❌ Cons Dependency array can be confusing and may cause bugs or infinite loops Often overused for things that don’t really need an effect Debugging async code inside useEffect isn’t always easy Poor usage can lead to performance issues 💡 Takeaway: Use useEffect only when you’re dealing with real side effects — not as a default solution. #ReactJS #Frontend #WebDevelopment #JavaScript #ReactHooks
To view or add a comment, sign in
-
Think useOptimistic is React's silver bullet for smooth UI updates? This deep dive argues it's not. The hook is useful but doesn't solve race conditions on its own and makes optimistic UI more complex when combined with concurrent features like transitions. Read the critique: https://lnkd.in/dfCmaPxF #ReactJS #WebDev #Frontend #JavaScript
To view or add a comment, sign in
-
-
5 React.js Performance Optimization Techniques I Use on Every Project Code splitting with React.lazy() → Reduces initial bundle size by 40-60% Memoization (useMemo, React.memo) → Prevents unnecessary re-renders Virtual scrolling for large lists → Handles 10K+ items smoothly Debouncing expensive operations → Saves thousands of API calls Bundle size analysis → Catches bloat before production Performance isn't a feature—it's a requirement. Save this for your next optimization sprint! 📌 #ReactJS #WebPerformance #FrontendDevelopment #JavaScript
To view or add a comment, sign in
-
-
Hydration mismatch is a common issue in React & Next.js when the Server and Client render different outputs. It’s usually caused by: • Browser-only APIs (window, localStorage) • Dynamic values (Math.random(), Date) • Client-only conditional rendering The fix? → Keep the first render consistent → Move client-only logic into useEffect #NextJS #ReactJS #Frontend #WebDevelopment #JavaScript
To view or add a comment, sign in
-
-
One Next.js concept that confuses almost everyone 🤯 If components are server-side by default, why do we still write use server? The answer is simple: UI rendering and server logic are two different things. Did this confuse you before? 👇 Share your thoughts in the comments #NextJS #ReactJS #WebDevelopment #FrontendDevelopment #JavaScript #ServerComponents #ServerActions #ProgrammingReels #DevCommunity #LearnToCode
To view or add a comment, sign in
-
Why useEffect runs twice in React (and it’s NOT a bug) 👇 In development mode, React intentionally runs effects twice to help you: • detect side effects • enforce cleanups • avoid hidden bugs In production, it runs once. Fighting React here usually means misunderstanding React. Have you ever been confused by this behavior? #ReactJS #JavaScript #Frontend #WebDev #ReactHooks #TechLearning
To view or add a comment, sign in
-
🚀 Understanding the useEffect Hook in React useEffect is a powerful hook used to handle side effects in functional components, such as: API calls Subscriptions & event listeners Timers Cleanup on unmount Key concepts covered ✔️ Mount → runs after initial render ✔️ Update → re-runs when dependencies change ✔️ Unmount → cleanup to prevent memory leaks ✔️ Dependency array → controls when the effect runs Strong understanding of hooks leads to cleaner, scalable, and more predictable React applications. #ReactJS #useEffect #FrontendDevelopment #JavaScript #WebDevelopment #ReactHooks #SoftwareEngineering #LearningJourney
To view or add a comment, sign in
-
-
Using array index as a key in React works… until it doesn’t ⚠️ At first, everything looks fine. No errors. No warnings. But the moment you: - insert an item - remove one - or reorder the list state starts jumping between components. This happens because React uses the key to decide component identity. Index is not identity. It’s position. If the order changes, React gets confused — and the bug is silent. If a list can change, the index is almost never the right key. What’s the worst bug you’ve seen caused by this? #React #Frontend #JavaScript #WebDevelopment #ReactJS
To view or add a comment, sign in
-
Understanding useCallback can save you from unnecessary re-renders and performance headaches in React ⚛️ If you’re passing functions as props, useCallback helps keep references stable and your components efficient. Small hook. Big impact. 🚀 #ReactJS #FrontendDevelopment #WebDevelopment #JavaScript #ReactHooks
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