4 ms·
I'm not sure of the exact logic it uses, but it appears to me that when React finds a new component in place of an old one of the same class, it just changes th
by svachalek 11y ago
I'm not sure of the exact logic it uses, but it appears to me that when React finds a new component in place of an old one of the same class, it just changes the props on the old component (and calls componentWillReceiveProps) which bypasses some of the lifecycle calls.
Also, I believe Chrome and Firefox (and hopefully other) garbage collectors use a generational algorithm which makes it very cheap to throw away short-lived objects.
Of course it's more efficient just to mutate state, but these factors and other optimizations should mitigate the added cost and I think for most applications, the wasted cycles are not going to be much concern.