DEV Community

Cover image for Server Fallback in React SPAs (2025 Update): Prevent 404 Errors on Refresh πŸš€
Yogesh Bamanier
Yogesh Bamanier

Posted on • Edited on

Server Fallback in React SPAs (2025 Update): Prevent 404 Errors on Refresh πŸš€

πŸš€ Understanding React Fiber: Incremental vs Concurrent Rendering

React Fiber introduced a new way to handle rendering in React, allowing work to be split into small chunks (slices), paused, resumed, and even discarded. But how does this affect what the browser actually sees? Let’s break it down.


🧩 1. Work-in-Progress (WIP) and Slices

  • Each Fiber node is a unit of work.
  • Rendering is divided into time slices.
  • In each slice, React processes as many Fibers as it can before yielding back to the browser.

πŸ‘‰ Important: Slices are only about preparing work. They do not directly affect the DOM.


πŸ›‘ 2. Pausing vs Discarding

  • Pausing β†’ If React runs out of time, it saves progress and continues in the next slice.
  • Discarding β†’ If a new higher-priority update comes in, React throws away unfinished WIP and restarts.

🎨 3. When Does the Browser See Updates?

  • During Render (slices) β†’ React is only preparing the Fiber tree. ❌ No DOM updates yet.
  • At Commit Phase β†’ React flushes the finished tree to the DOM in one atomic step. βœ… Browser paints changes here.

πŸ‘‰ Even if rendering happens in 5 slices, the browser only updates after commit.


πŸŒ€ 4. Why Is It Still Called Incremental Rendering?

  • React doesn’t block the browser with a long, synchronous render.
  • Rendering work is split across slices.
  • Browser stays responsive in between.

πŸ”‘ The incremental part is about time-slicing the render work, not about incremental DOM commits.


πŸ”„ 5. Example Walkthrough

Imagine typing into an input that triggers a huge list render.

Without Fiber (old stack reconciler)

  • Input change β†’ whole list renders synchronously.
  • Browser frozen until work completes.

With Fiber (incremental rendering)

  • Slice 1: Input Fiber processed.
  • Yield β†’ browser stays responsive.
  • Slice 2–5: List Fibers processed gradually.
  • Final slice β†’ Commit happens, DOM updated.

⚑️ 6. Concurrent Rendering

Concurrent rendering builds on incremental rendering by allowing partial commits.

  • Commit input immediately β†’ user sees instant feedback.
  • Render list in background.
  • If user types again β†’ discard old WIP and restart fresh.

βœ… This makes UI feel even smoother.


⏱️ 7. Timeline Comparison

Incremental Rendering

Top comments (0)