When I pass in only one item as my items, I'm seeing ItemsCard's constructor being called twice:
Once as a result of being in the elementsToMeasure collection, and then again after a state change when the element has been measured. On that second pass 'cloneElement' adds the itemRect property to the object props, and as a result, the initial object is torn down and removed from the DOM and the new item is added.
Is there any way to make this more efficient so that it doesn't recalcuate, as my ItemCard is quite a large component.
Is there some optimization I need to do in my ItemCard? I attempted to add the lifecycle events for componentWillReceiveProps but it is never called due to cloning.
I'm creating my grid like this:
When I pass in only one item as my items, I'm seeing
ItemsCard
's constructor being called twice: Once as a result of being in theelementsToMeasure
collection, and then again after a state change when the element has been measured. On that second pass 'cloneElement' adds theitemRect
property to the object props, and as a result, the initial object is torn down and removed from the DOM and the new item is added.Is there any way to make this more efficient so that it doesn't recalcuate, as my
ItemCard
is quite a large component.Is there some optimization I need to do in my
ItemCard
? I attempted to add the lifecycle events forcomponentWillReceiveProps
but it is never called due to cloning.