-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix TypeScript error on Calendar component due to children
#6334
base: main
Are you sure you want to change the base?
Conversation
@haydenbleasel is attempting to deploy a commit to the shadcn-pro Team on Vercel. A member of the Team first needs to authorize it. |
children
* Scaffold Knock integration * Misc fixes, regen lockfile * Collab on Notifications (#388) * update env vars * update notif provider * add secret key for server sdk * create feed component * make provider client --------- Co-authored-by: Jeff Everhart <jeffeverhart383@gmail.com> * Extract notifications into new package * Update feed.tsx * Move provider to package * Scaffold doc * Update env.ts * change key and stub docs (#393) * use public api key for feed * stub out docs * add link to keys docs * Fix keys * Add notifications feed to app * Update notifications.mdx * Temporary shadcn/ui patch shadcn-ui/ui#6334 --------- Co-authored-by: Jeff Everhart <jeffeverhart383@gmail.com>
@@ -54,10 +54,10 @@ function Calendar({ | |||
...classNames, | |||
}} | |||
components={{ | |||
IconLeft: ({ className, ...props }) => ( | |||
IconLeft: ({ className, children, ...props }) => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach might be misleading since children
are destructured but not actually used anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe try to explicitly type the IconLeft
and IconRight
like this:
type IconProps = React.SVGProps<SVGSVGElement> & {
className?: string;
};
const IconLeft: FC<IconProps> = ({ className, ...props }) => (
<ChevronLeft className={cn("h-4 w-4", className)} {...props} />
);
const IconRight: FC<IconProps> = ({ className, ...props }) => (
<ChevronRight className={cn("h-4 w-4", className)} {...props} />
);
components={{
IconLeft,
IconRight,
}}
{...props}
/>
Problem
react-day-picker
'sDayPicker
component takes a property calledcomponents
, which in turn we are passingIconLeft
andIconRight
. The properties for these two components takeschildren
, which Radix's icons do not like since they're typed as SVG elements. As such, you end up with the following TS error:Fix
This pull request includes changes to two
Calendar
components to ensure that theIconLeft
andIconRight
components destructurechildren
from the props before spreading them on to Radix's icons. This change was applied to both the default and New York versions of the calendar.