feat: add render prop for custom element rendering in Link#794
feat: add render prop for custom element rendering in Link#794rohanchkrabrty merged 1 commit intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThis PR adds a Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/raystack/components/link/link.tsx (1)
1-1: 💤 Low valuePrefer
import typeforuseRendersince it's used only as a type namespace.
useRenderis only referenced in a type position (useRender.ComponentProps<'a'>). A value import pulls in the runtime binding unnecessarily and may cause issues underverbatimModuleSyntaxorisolatedModules.♻️ Suggested fix
-import { useRender } from '@base-ui/react'; +import type { useRender } from '@base-ui/react';🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/raystack/components/link/link.tsx` at line 1, Change the import of useRender to a type-only import because it's only used in a type position (useRender.ComponentProps<'a'>); replace the value import "import { useRender } from '@base-ui/react'" with a type import "import type { useRender } from '@base-ui/react'" and confirm there are no runtime references to useRender in link.tsx so the type-only import is valid.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/www/src/content/docs/components/link/props.ts`:
- Around line 13-21: The render prop is typed only as ReactElement but should
also accept a render function like the Text and Button components; update the
Link props declaration (the render property) to a union that accepts a
ReactElement or a render function (e.g., ReactElement | ((props: any) =>
ReactElement) or the project's shared RenderFunction type), and update the JSDoc
to reflect that it can be either an element or a render function so consumers
and TS inference match other components.
---
Nitpick comments:
In `@packages/raystack/components/link/link.tsx`:
- Line 1: Change the import of useRender to a type-only import because it's only
used in a type position (useRender.ComponentProps<'a'>); replace the value
import "import { useRender } from '@base-ui/react'" with a type import "import
type { useRender } from '@base-ui/react'" and confirm there are no runtime
references to useRender in link.tsx so the type-only import is valid.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c80932c6-145d-4ea4-a459-59237d56fce7
📒 Files selected for processing (4)
apps/www/src/content/docs/components/link/index.mdxapps/www/src/content/docs/components/link/props.tspackages/raystack/components/link/__tests__/link.test.tsxpackages/raystack/components/link/link.tsx
Summary
renderprop toLink, forwarded to the underlyingText/useRender, so consumers can swap the rendered element (e.g. routerLink) instead of always emitting<a/>.LinkPropsagainstuseRender.ComponentProps<'a'>and drop the requiredhref(custom render targets may handle navigation themselves); default render remains<a />.props.tsand add a "Custom render" example to the Link docs page.