Skip to content
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

react-icons v5 (required by ui/package.json) is not type compatible with icon prop in components like Alert #1359

Open
2 tasks done
akshetpandey opened this issue Apr 11, 2024 · 1 comment

Comments

@akshetpandey
Copy link

  • I have searched the Issues to see if this bug has already been reported
  • I have tested the latest version

Steps to reproduce

Sample form https://flowbite-react.com/docs/components/alert#alert-with-icon

import { HiInformationCircle } from "react-icons/hi";
import { Alert } from "flowbite-react";

function Component() {
  return (
    <Alert color="failure" icon={HiInformationCircle}>
      <span className="font-medium">Info alert!</span> Change a few things up and try submitting again.
    </Alert>
  );
}

This will produce a TS error: HiInformationCircle:IconType is not assignable to icon:FC<SVGProps<SVGSVGElement>>

@victorfunes
Copy link

I found the same, and as a work around I defined this type:

export type IconSVGProps = React.PropsWithoutRef<React.SVGProps<SVGSVGElement>> & React.RefAttributes<SVGSVGElement>;
export type FlowbiteIconProps = IconSVGProps & {
  title?: string;
  titleId?: string;
};

export type FlowbiteIcon = FC<Omit<SVGProps<SVGSVGElement>, "ref">> & FlowbiteIconProps;

then you can do something like this in the flowbite components with the issue:

icon={FilmIcon as FlowbiteIcon}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants