-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[Bug]: Unexpected behavior : react/no-multi-comp #3635
Comments
"use client";
import { ChevronLeft, ChevronRight } from "lucide-react";
import * as React from "react";
import { DayPicker } from "react-day-picker";
import { cn } from "@/lib/utils";
import { buttonVariants } from "../Button/Button";
export type CalendarProps = React.ComponentProps<typeof DayPicker>;
function Calendar({
className,
classNames,
showOutsideDays = true,
...props
}: CalendarProps): JSX.Element {
return (
<DayPicker
showOutsideDays={showOutsideDays}
className={cn("p-3", className)}
classNames={{
months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
month: "space-y-4",
caption: "flex justify-center pt-1 relative items-center",
caption_label: "text-sm font-medium",
nav: "space-x-1 flex items-center",
nav_button: cn(
buttonVariants({ variant: "outline" }),
"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"
),
nav_button_previous: "absolute left-1",
nav_button_next: "absolute right-1",
table: "w-full border-collapse space-y-1",
head_row: "flex",
head_cell:
"text-slate-500 rounded-md w-9 font-normal text-[0.8rem] dark:text-slate-400",
row: "flex w-full mt-2",
cell: "text-center text-sm p-0 relative [&:has([aria-selected])]:bg-slate-100 first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20 dark:[&:has([aria-selected])]:bg-slate-800",
day: cn(
buttonVariants({ variant: "ghost" }),
"h-9 w-9 p-0 font-normal aria-selected:opacity-100"
),
day_selected:
"bg-primary text-slate-50 hover:bg-primary hover:text-slate-50 focus:bg-primary focus:text-slate-50 dark:bg-slate-50 dark:text-slate-900 dark:hover:bg-slate-50 dark:hover:text-slate-900 dark:focus:bg-slate-50 dark:focus:text-slate-900",
day_today:
"bg-primary/20 text-primary dark:bg-slate-800 dark:text-slate-50",
day_outside: "text-slate-500 opacity-50 dark:text-slate-400",
day_disabled: "text-slate-500 opacity-50 dark:text-slate-400",
day_range_middle:
"aria-selected:bg-slate-100 aria-selected:text-slate-900 dark:aria-selected:bg-slate-800 dark:aria-selected:text-slate-50",
day_hidden: "invisible",
...classNames,
}}
components={{
// eslint-disable-next-line react/no-multi-comp
IconLeft: ({ ...props }) => <ChevronLeft className="h-4 w-4" />,
// eslint-disable-next-line react/no-multi-comp
IconRight: ({ ...props }) => <ChevronRight className="h-4 w-4" />,
}}
{...props}
/>
);
}
Calendar.displayName = "Calendar";
export default Calendar; |
indeed , the |
@ljharb tried this but still getting the error |
then i don't think there's a way to avoid it here; these are components, so you can either define them in another file or ignore the warning, as you've done. |
Okay @ljharb , Thanks for Help |
Is there an existing issue for this?
Description Overview
I'm using eslint-plugin-react@7,33,2 and I am getting false positive error
Declare only one React component per file react/no-multi-com issue reported.
I've seen the same issue in #3412
Expected Behavior
It's is working using
"react/no-multi-comp": ["error", { "ignoreStateless": true }]
, but It should work without iteslint-plugin-react version
v7.33.2
eslint version
v8.47.0
node version
v16.15.1
The text was updated successfully, but these errors were encountered: