News for hackers. Stuff that matters.
Re:Designing simpler React components by CGamesPlay on Saturday March 26, 2016 @09:52PM (#11368465)
How does all of the cloning affect performance? It feels wasteful to create these short-lived components that are explicitly discarded for slightly modified ones, but is that actually a problem?
Re:Designing simpler React components by svachalek on Saturday March 26, 2016 @10:26PM (#11368581)
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.

Re:Designing simpler React components by pspeter3 on Monday March 28, 2016 @09:22AM (#11374077)
You're only cloning the JSON representation of the components, not the component instances.