React 19 lets you render a context directly instead of <Ctx.Provider>. That
form throws on the client and renders nothing on the server:
const Ctx = createContext('default')
const Read = () => <span>{useContext(Ctx)}</span>
createRoot(el).render(<Ctx value="provided"><Read /></Ctx>)
Summary by CodeRabbit#
New Features
- Context objects can now be rendered directly as providers using React 19 syntax, such as
<Context value={...}>.
- Context values propagate correctly to descendants during client rendering and server-side rendering.
- Direct context providers work with consumers and can be combined with traditional provider syntax.
Bug Fixes
- Fixed errors and missing context values when rendering contexts directly as elements.
- Context updates now propagate correctly across re-renders.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Advanced
Run ID:
76d24c59-dc11-462b-81d8-6a341b38d666📥 Commits
Reviewing files that changed from the base of the PR and between aa8730af30298af691e75b2de73b6510200c2ddc and 9d6528a9f6ddeb93e3c37210e665bf1e63b0761d.
📒 Files selected for processing (6)
.changeset/context-as-provider.mdpackages/redact/src/dom/features/context/full.tspackages/redact/src/dom/features/context/stub.tspackages/redact/src/react/context.tspackages/redact/src/server/walk.tstests/context-as-provider.test.tsxIncluded review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.
📝 Walkthrough
Walkthrough#
This change lets a context object render as its own provider. Client and server renderers recognize the context marker. The context API exposes callable provider behavior. Tests cover propagation, updates, nested providers, consumers, and server rendering.
Changes#
Context Provider Support
packages/redact/src/react/context.tsContext<T>now supports callable provider usage and stores a self-reference duringcreateContext.packages/redact/src/dom/features/context/*,tests/context-as-provider.test.tsxpackages/redact/src/server/walk.ts,tests/context-as-provider.test.tsx,.changeset/context-as-provider.mdPriority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Sequence Diagram(s)#
Suggested reviewers:
tannerlinsleyMerge Risk: ⚪ Minimal · up to
9d652Direct context-provider rendering is implemented consistently across the public API, client paths, and server rendering, with relevant test coverage. No merge-blocking risk is evident.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
Full details: Docstring Coverage
Explanation
Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 5 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches
🧪 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