Skip to main content

Introduction

Reconciliation is an implementation detail in Litho’s layout calculation process. Instead of recreating the entire layout tree for every update, reconciliation enables Litho to clone the unmodified subtrees and only recreate the subtree that has changed.

When using Litho, the component hierarchy is determined by what is returned by the OnCreateLayout method. On the next state or prop update, the OnCreateLayout may return a different tree of components. Litho uses reconciliation to determine which components should be re-created and which can be re-used (read cloned).

In essence, this means Litho will not call (most) lifecycle methods of components which were unaffected by the update. Reconciliation enforces the requirement that component specs must be immutable and should not rely on side-effects to achieve any desired behaviour.

note

As of December 2020, reconciliation is only implemented for state updates.

Tradeoffs

It's important to remember that reconciliation is just an implementation detail; it's used for optimsation aimed at improving performance and doesn't affect the end result.

To clariify, re-creation in this context means calling OnCreateLayout for the modified component, it doesn’t mean Litho will unmount and remount them. Litho will only mount and unmount items that have changed.

In order to reconcile changes, Litho keeps the previous component hierarchy in memory. This increases memory usage and can potentially increase OOMs.