The extra render in the effect version is worse than wasted work. Children and their own effects see that in-between render with the old total, so an analytics call or a fetch keyed on total can fire once with the stale value before the corrected one lands. Calculating during render removes that window completely.
Ha, I didn't even know that was a thing, thanks. That's actually why .me doesn't have that problem: there's no separate step for the total. When you write the quantity, the total is already updated, so nothing ever reads the old one in between.
Tarun Sharma
The extra render in the effect version is worse than wasted work. Children and their own effects see that in-between render with the old total, so an analytics call or a fetch keyed on total can fire once with the stale value before the corrected one lands. Calculating during render removes that window completely.