Reconciler¶
Diffs successive virtual trees and applies the smallest set of native
mutations that bring the on-screen view tree in line with the new
description. The reconciler is platform-agnostic; it talks to native
widgets exclusively through the
NativeViewRegistry.
Virtual-tree reconciler.
Maintains a tree of VNode objects
(each wrapping a native view) and diffs incoming
Element trees to apply the minimal set of
native mutations.
Supports:
- Native elements (
typeis a string like"Text"). - Function components (
typeis a callable decorated withcomponent). Their hook state is preserved across renders. - Provider elements (
type == "__Provider__"), which push and pop context values during tree traversal. - Error boundary elements (
type == "__ErrorBoundary__"), which catch exceptions in child subtrees and render a fallback. - Key-based child reconciliation for stable identity across re-renders.
- Post-render effect flushing. After each mount or reconcile pass, all queued effects are executed so they see the committed native tree.
Classes:
| Name | Description |
|---|---|
VNode |
A mounted |
Reconciler |
Create, diff, and patch native view trees from |
VNode
¶
A mounted Element plus its native view.
The reconciler walks parallel trees of VNode and incoming
Element to compute the minimal set of native mutations.
Attributes:
| Name | Type | Description |
|---|---|---|
element |
The |
|
native_view |
The platform-native view (e.g., an Android |
|
children |
Ordered list of child |
|
hook_state |
Any
|
The component's
|
Reconciler
¶
Reconciler(backend: Any)
Create, diff, and patch native view trees from Element descriptors.
After each mount or
reconcile call the
reconciler walks the committed tree and flushes all pending effects
so effect callbacks run after native mutations are applied.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
Any
|
An object implementing the native-view protocol
( |
required |
Methods:
| Name | Description |
|---|---|
mount |
Build native views from |
reconcile |
Diff |
Next steps¶
- Read the high-level walkthrough in Reconciliation.
- See how native widgets are registered in Native views.