LearnNewsExamplesServices
Frontmatter
id7086
titleEnhance Functional Component VDOM Reconciliation
stateClosed
labels
enhancement
assigneestobiu
createdAtJul 21, 2025, 2:33 AM
updatedAtJul 21, 2025, 11:49 AM
githubUrlhttps://github.com/neomjs/neo/issues/7086
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJul 21, 2025, 11:49 AM

Enhance Functional Component VDOM Reconciliation

Closed v10.0.0 enhancement
tobiu
tobiu commented on Jul 21, 2025, 2:33 AM

Problem: Functional components recreate their VDOM from scratch on every render. This discards any worker-generated IDs that were synced back to the component's vdom object. When a subsequent update occurs, the VDOM worker receives a keyless VDOM tree, which it must compare against the old, keyed vnode tree. This leads to inefficient diffing, causing the VDOM engine to generate excessive removeNode and insertNode deltas instead of minimal, targeted updates. This forces developers to manually add stable ids to all conditional child nodes as a workaround.

Solution: Inside src/functional/component/Base.mjs, modify the onEffectRunStateChange() method. Just before updateVdom() is called, add a call to me.syncVdomIds().

This will "re-hydrate" the newly created, keyless VDOM with the stable IDs from the previously rendered vnode tree. This ensures that the VDOM worker always receives a fully-keyed VDOM, allowing it to perform a hyper-efficient diff and generate minimal, correct deltas.

Benefits:

  • Improved Performance: Drastically reduces the number of deltas for functional component updates.
  • Enhanced Developer Experience: Removes the requirement for developers to manually add stable ids to child nodes in functional components.
  • Encreased Robustness: Centralizes the ID synchronization logic within the FunctionalBase class, making all functional components more stable by default.

File to Change: src/functional/component/Base.mjs

tobiu assigned to @tobiu on Jul 21, 2025, 2:33 AM
tobiu added the enhancement label on Jul 21, 2025, 2:33 AM
tobiu referenced in commit 0f8bcb4 - "Enhance Functional Component VDOM Reconciliation #7086" on Jul 21, 2025, 2:34 AM
tobiu closed this issue on Jul 21, 2025, 11:49 AM