feat(ContentPreview): Noop for custom preview render prop#4458
feat(ContentPreview): Noop for custom preview render prop#4458ahorowitz123 wants to merge 2 commits intobox:masterfrom
Conversation
Refactors the custom preview API from children pattern to render prop
pattern for better ergonomics and clearer developer intent.
Changes:
- Replace children?: React.Node with renderCustomPreview
- Update CustomPreviewWrapper to call render function
- Wrap rendered content in fragment to satisfy ErrorBoundary
- Update all 119 tests to use render prop syntax
- Update JSDoc comments and examples
Before (children pattern):
<ContentPreview fileId="123" token={token}>
<MarkdownEditor />
</ContentPreview>
After (render prop pattern):
<ContentPreview
fileId="123"
token={token}
renderCustomPreview={(props) => <MarkdownEditor {...props} />}
/>
Benefits:
- More explicit intent - function signature shows available props
- Better TypeScript/Flow type inference
- More idiomatic React pattern
- Easier conditional rendering and prop transformation
Testing:
- All 119 ContentPreview tests passing
- Flow: 0 errors
- ESLint: clean
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The onKeyDown handler was still checking the removed children prop, which meant hotkey skipping never occurred for custom previews. Updated the conditional to check renderCustomPreview instead, ensuring custom previews can implement their own keyboard shortcuts without conflicts. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
WalkthroughThe PR replaces the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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. Comment |
Noop to release refactor(ContentPreview): change from children to render prop pattern
Summary by CodeRabbit
Breaking Changes
renderCustomPreviewprop for custom preview content instead ofchildren. Users will need to update their implementation to pass a render function instead.Tests