flowbite-react: Sidebar.Collapse and other components fails to accept heroicons/react
Describe the bug
I have just upgraded to 0.4.11 and the ts compiler fails when using icon property in Dropdown.Item and Sidebar.Collapse with @heroicons/react. The error message:
Type 'ForwardRefExoticComponent<Omit<SVGProps<SVGSVGElement>, "ref"> & { title?: string | undefined; titleId?: string | undefined; } & RefAttributes<SVGSVGElement>>' is not assignable to type 'FunctionComponent<SVGProps<SVGSVGElement>>'
To Reproduce Steps to reproduce the behavior:
- Create a CRA.
- Install
flowbite-reactfollowing the docs. - Install
@heroicons/react. - Use the sidebar code, but with
heroicons’ icons. Sample code:
import {Cog6ToothIcon, BuildingOffice2Icon} from "@heroicons/react/24/outline";
// ...
<Sidebar>
<Sidebar.Collapse icon={Cog6ToothIcon} label="Configuration" open={false}>
<Sidebar.Item icon={BuildingOffice2Icon}>
Corporation
</Sidebar.Item>
</Sidebar.Collapse>
</Sidebar>
Note The same problem was confirmed for
Dropdown,TextInput… It is possible that other components are also affected.
Expected behavior It should compile without issues.
System information:
- OS: MacOS
Project information:
- Typescript: 5.1.6
- Tailwind: 3.3.2
- Flowbite: 1.7.0
- Flowbite React: 0.4.11
- Heroicons: 2.0.18
- Type: Vite
Additional context I have updated all the libraries and ts compiler, as well as migrated to vite. Maybe I did something wrong that affected to this behaviour.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 19
All right, thank you.
~I think that we need to replace this:~
https://github.com/themesberg/flowbite-react/blob/5acb61263bfeb0805a50a73b005673227482c5c0/src/components/Sidebar/SidebarItem.tsx#L35
~with this:~
~Of course, it will be necessary to be replaced in all places where we are using
FC<ComponentProps<'svg'>>… And, it would be necessary to test it first, but this is the basic idea and the reason for the issue. Also, it is worth testing if it will not be a problem when usingreact-iconsinstead of just theheroiconspackage.~UPDATE: I tested and this approach doesn’t solve the issue.
If someone is interested in testing and providing a PR for this, I’ll review and release a patch ASAP.
@victorfunes could you do me a favor and also test if the issue happens for the
TextInputcomponent with an icon?