Fixes the React 19 compatibility gaps reported in #27 and #28, with contributor credit preserved.
- Support
<Context value={value}> on the client, server, and during hydration. Context.Provider === Context, so changing syntax does not remount children.
- Keep refs in
createElement and cloneElement props. Preserve undefined-ref cloning, older element-level refs, and own props named constructor, toString, or hasOwnProperty.
- Simplify prop filtering and provider state, and put the existing server host-element check first.
- Keep synchronous scheduling and feature-stub behavior unchanged.
Published bundle sizes, gzip bytes:
| Bundle | Before | After |
|---|
| Nano client total | 15,534 | 15,503 |
| Default client total | 23,311 | 23,301 |
| Full client total | 28,159 | 28,125 |
| Server | 8,964 | 8,957 |
All 20 measured published entries are flat or smaller in minified and gzip bytes. All three combined client bundles also shrink with Brotli. Some isolated feature-stub Brotli bundles grow by 7 to 20 bytes. No size budget was raised.
The final production comparisons cover 23 client workloads and four Node SSR workloads, each with five independent blocks, rotated execution order, completed-work checks, and an identical React control. No workload has a 95% timing interval entirely on the slower side. This is not a formal equivalence guarantee. Element factories take 17% to 28% less time in the mixed client run; several prop-heavy render cases improve by 3% to 5%. The 2,400-row click case keeps its 1.1 ms median commit time, with p95 changing from 1.21 to 1.30 ms. Retained heap, DOM nodes, and listeners stay flat.
Full measurements, caveats, rejected candidates, and reproduction steps.
Local validation:
pnpm test:pr: 1,607 tests pass, 91 existing skips; types, package build, published-entry checks, and size budgets pass.
- Chrome: core 356, native transitions 80, retained content 61, resources 75 tests pass. These suites overlap.
- All 29 new provider, ref, and own-prop cases pass against React 19.3. The shared native-transition reference suite passes all 77 cases.
- Full and nano Vite builds cover direct,
.Provider, and legacy provider forms, including disabled context behavior.
- Fixed a native-test teardown race also reproduced on the unchanged baseline. Owning roots now unmount before browser transitions are skipped or drained. Animation-runtime error handling is unchanged.
- Added three anchor-cache regression tests while reviewing #30 separately. Its optimization is not included here because the revised candidate changes DOM order and increases bundle size.
GitHub's Test job is still queued. Local checks are green; this should not merge until CI runs and passes.
Summary by CodeRabbit#
New Features
- Added support for using React 19 context objects directly as providers, including client rendering, server rendering, hydration, and nested contexts.
- Improved
ref handling in element creation and cloning, including ref forwarding through components and preservation of existing refs when appropriate.
- Preserved props with reserved names such as
constructor, toString, and hasOwnProperty.
Bug Fixes
- Fixed DOM ordering and sibling updates when portals move or neighboring content is revealed or replaced.
📝 Walkthrough
Walkthrough#
This change adds React 19 direct context provider support, preserves refs in
createElementandcloneElement, updates client and server rendering, and adds tests, benchmarks, compatibility configuration, and release documentation.Changes#
React context and ref parity
packages/redact/src/react/context.ts,packages/redact/src/dom/features/context/*packages/redact/src/server/walk.tspackages/redact/src/react/element.tscreateElementandcloneElementcopyrefinto props while preserving legacy refs and explicit null or undefined behavior.tests/context-*.tsx,tests/element-*.tsx,tests/vite-plugin.test.ts,scripts/*config.mjs,tests/*transition*.tsxbenchmarks/*,scripts/compare-ssr.mjs,.changeset/context-ref-parity.mdChild-chain regression coverage
scripts/child-chain-cache.config.mjs,tests/child-chain-cache-regressions.test.tsxPriority: ➖ Normal
Estimated code review effort: 4 (Complex) | ~45 minutes
Change: Bug fix
Sequence Diagram(s)#
Merge Risk: 🔵 Low · up to
fe328Reference-React runs can execute the new anchor regression before its initial tree is committed, causing flaky or invalid compatibility coverage. Synchronize the renders or exclude this suite from reference runs before merging.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
Full details: Docstring Coverage
Explanation
Docstring coverage is 2.63% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 38 functions across 23 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share