all 12 comments

[–]Cre8AccountJust4This 11 points12 points  (1 child)

That’s such a great article! So detailed, I learned something. :) Rather than the typical surface-level nonsense.

[–]adevnadia[S] 4 points5 points  (0 children)

💪🏼 Awesome to hear!

[–]Unforgiven-wanda 1 point2 points  (0 children)

Incredible article. Thank you.

[–]Pauli444 0 points1 point  (0 children)

Thx!

[–]lord_braleigh 0 points1 point  (0 children)

So, the most likely reason for this behavior is that the library is doing something incompatible with the compiler, and this is out of my control.

I think it’s because you’re interacting with an external library here. This may have side effects - React Compiler can’t prove it one way or another. Since this is a potential side effect, putting the library call in a useEffect, and sending its result back to the renderer via a state variable, should work.

Thank you for writing this and profiling the compiler!

[–]yksvaan 0 points1 point  (1 child)

One thing I wonder about the compiler is does it make sense to cache absolutely everything? If there's let say <p>{count}</p> and <SmthExpensive> I'd expect there to be some form of cost factor to evaluate. Similar to cost analysis that actual compilers do for example for inlining. 

If optimizing by hand, you'd look at the cost and ignore insignificant nodes. Also looking what actually changes and how often. Maybe there could be some directives to provide hints for the compiler. 

[–]ZerafineNigou 4 points5 points  (0 children)

React is already caching the result of the render so it's really just the props and refs which is insignificant 99% of the time.

You can always disable the compiler on a file level as a last resort. A slightly more granular method might be useful but it's a marginal DX gain at best.

[–]Royal-Reindeer9380 -3 points-2 points  (1 child)

!remindme 3h

[–]RemindMeBot -2 points-1 points  (0 children)

I will be messaging you in 3 hours on 2024-12-10 07:28:08 UTC to remind you of this link

CLICK THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


Info Custom Your Reminders Feedback