Faster State Update

Why do we need faster state updates?

When a state update occurs, the whole component tree is being created again. Often times, we don't notice any perf issue as it's being computed on a background thread. However, multiple state updates can cause perf issues in some cases. In Sections for example, state updates are mostly computed on the main thread.

What does it mean faster state updates?

In practice, it means that when a state update occurs we don't have to recompute the whole component tree, but we can reuse part of it.

CKRenderComponent and FBSectionRenderComponent support faster state updates out-of-the-box.

How does it work?

When there is a state update, we mark the branch (component tree branch) of the state update from the component with the state update until the root as dirty.

When the infrastructure constructs a render component, in case of a state update, before calling the render method it checks if the component is not dirty - If it's not, the previous component and its subtree are being reused.

Faster State Update

New life cycle method

When a component is being reused, a new life cycle method is being called:

// This method is being called on the new component with the reused component.
- (void)didReuseComponent:(id<CKComponentRenderProtocol>)component;