feat: add stable React node keys - #11
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a stable “key” API for MoonBit VirtualNodes so React can reconcile dynamic collections without warnings, then applies it to the TodoMVC example and tightens browser regression checks to fail on React console warnings/errors.
Changes:
- Added
VirtualNode::with_keyplus the needed JS interop to assign reconciliation keys across elements, components, fragments, and text. - Keyed TodoMVC list items by stable todo IDs to avoid index-based reconciliation.
- Made the Playwright TodoMVC regression fail on browser console warnings/errors, and documented the new API (README/changelog) while updating the generated interface.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/todomvc.spec.mjs | Captures console warnings/errors during the TodoMVC flow and fails the test if any occur. |
| src/react.mbt | Adds VirtualNode::with_key and JS interop (cloneElement) to support stable keys across node kinds. |
| src/react_test.mbt | Extends the test React stub with cloneElement and adds a regression test for with_key. |
| src/pkg.generated.mbti | Exposes VirtualNode::with_key in the generated public interface. |
| src/main/todolist.mbt | Applies stable keys to rendered todo items using todo.id. |
| README.md | Documents recommended with_key usage for dynamic collections. |
| index.html | Adds a data URL favicon to avoid console noise (e.g., favicon 404) in browser regressions. |
| CHANGELOG.md | Notes the new with_key API and stricter browser regression behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
18 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Verification
Relates to #7.