Comments on: React Internals: Which useEffect runs first? https://frontendmasters.com/blog/react-internals-which-useeffect-runs-first/ Helping Your Journey to Senior Developer Wed, 15 Oct 2025 23:15:27 +0000 hourly 1 https://wordpress.org/?v=6.9 By: Chris Coyier https://frontendmasters.com/blog/react-internals-which-useeffect-runs-first/#comment-44004 Wed, 15 Oct 2025 23:15:27 +0000 https://frontendmasters.com/blog/?p=5672#comment-44004 In reply to Luca.

Will look at that, thanks!

]]>
By: Luca https://frontendmasters.com/blog/react-internals-which-useeffect-runs-first/#comment-43979 Wed, 15 Oct 2025 18:57:48 +0000 https://frontendmasters.com/blog/?p=5672#comment-43979 Very very helpful article, especially with the graphics to make it easier to understand!

A quick note, there seems to be some words missing at the end of the sentence where it says “Commit phase is where actual DOM mutations and effect flushing (useEffect)”. Should there be a “take place” or “happen” at the end?

Cheers!

]]>
By: Rav https://frontendmasters.com/blog/react-internals-which-useeffect-runs-first/#comment-27181 Mon, 05 May 2025 15:26:55 +0000 https://frontendmasters.com/blog/?p=5672#comment-27181 Good one! Thanks.

]]>
By: Branko Toshin https://frontendmasters.com/blog/react-internals-which-useeffect-runs-first/#comment-27172 Mon, 05 May 2025 13:44:45 +0000 https://frontendmasters.com/blog/?p=5672#comment-27172 Hi @Teng, this article is great. Are there any other similar articles which are covering different kind of react internals?
Jser articles are great but quite code heavy.

]]>
By: SG https://frontendmasters.com/blog/react-internals-which-useeffect-runs-first/#comment-27001 Sat, 03 May 2025 13:10:56 +0000 https://frontendmasters.com/blog/?p=5672#comment-27001 In reply to Teng Wei Herr.

Hi @Teng, thank you very much for clearing the confusion.
I have a couple of more questions:

  1. You have written that “the entire React’s component lifecycle can be roughly divided into 3 phases: Trigger → Render → Commit”. But aren’t those three phases: Mounting -> Updating -> Unmounting? Are the former different from the latter ones?

  2. How many total Fiber Trees/DOM Trees will be created?

]]>
By: SG https://frontendmasters.com/blog/react-internals-which-useeffect-runs-first/#comment-26888 Fri, 02 May 2025 04:35:42 +0000 https://frontendmasters.com/blog/?p=5672#comment-26888 In reply to Mansour Koura.

If you observe the way Fiber tree is traversed, you will notice that its going from to , then starts committing phase from to and then it goes to

]]>
By: Teng Wei Herr https://frontendmasters.com/blog/react-internals-which-useeffect-runs-first/#comment-26885 Fri, 02 May 2025 04:02:59 +0000 https://frontendmasters.com/blog/?p=5672#comment-26885 In reply to SG.

Hi, author here. Let me help clarify a few things.

As mentioned in the article, in React, component rendering and effect committing happen in completely separate phases. The former occurs during the render phase, and the latter during the commit phase. They are separate walks, but the traversal algorithm is similar.

During the render phase, React traverses the fiber tree and renders the necessary components — which is why logs like “Xxx is rendered” appear first.

After that, in the commit phase, React traverses the fiber tree again to commit effects (i.e. your useEffect callbacks), which is why logs like “Xxx committed effect” appear later.

That’s why the logging order ends up like this:
Parent is rendered
Child is rendered
ParentSibling is rendered
Child committed effect
Parent committed effect
ParentSibling committed effect

Feel free to try it out using this link (https://codesandbox.io/p/sandbox/focused-cdn-32fkpx)

Regarding the animated image, it is only showing the commit phase traversal. I intentionally skipped the render phase traversal because this article is all about useEffect, and I wanted to avoid unrelated diagrams. Apologies for the confusion!

]]>
By: Mansour Koura https://frontendmasters.com/blog/react-internals-which-useeffect-runs-first/#comment-26869 Thu, 01 May 2025 23:26:06 +0000 https://frontendmasters.com/blog/?p=5672#comment-26869 In reply to SG.

As I got form the article this part: “Nothing happens in the first step, but in the second step, it commits effects.”

That committing the effect only happened in the committing step while rendering the body of the component (logs out of the effect) should happen first.

]]>
By: SG https://frontendmasters.com/blog/react-internals-which-useeffect-runs-first/#comment-26844 Thu, 01 May 2025 17:31:11 +0000 https://frontendmasters.com/blog/?p=5672#comment-26844 Wait, I have a question. In the second quiz example, isn’t the logging order supposed to be as below?

Parent is rendered
Child is rendered

Child committed effect
Parent committed effect

ParentSibling is rendered
ParentSibling committed effect

PS: The animated image traverses nodes only this way. Am I correct?

]]>
By: Maxy https://frontendmasters.com/blog/react-internals-which-useeffect-runs-first/#comment-26753 Wed, 30 Apr 2025 17:08:22 +0000 https://frontendmasters.com/blog/?p=5672#comment-26753 Really helpful

]]>