tabler-icons: 3.0 breaking changes?
I was using TablerIconProps in 2.x in the following way:
const lookup = Record<string, (props: TablerIconProps) => JSX.Element) = {
key: IconFoo,
key2: IconBar, ...
In 3.0 TablerIconProps is has been renamed IconProps, but also because the icons are now a ForwardRefExoticComponent, they no longer match (props: IconProps) => JSX.Element…
Type 'ForwardRefExoticComponent<Omit<IconProps, "ref"> & RefAttributes<SVGSVGElement>>' is not assignable to type '(props: IconProps) => Element'.
Type 'ReactNode' is not assignable to type 'Element'.
Type 'undefined' is not assignable to type 'ReactElement<any, any>'
changing the type to (props: IconProps) => ReactNode solves the problem…
Should this have been documented in the release notes for 3.0?
Also, I think changing the name from TablerIconsProps to IconProps was a poor choice, since every other IconXXX export is an actual Icon… what if someone wanted to make an icon for properties and wanted to call it IconProps?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 9
- Comments: 17 (12 by maintainers)
I’ve upgraded from version
2.47.0to3.2.0and created this custom type to address backward compatibility issues.I hope it’s useful.
I believe they merged my PR on April 30…
https://github.com/tabler/tabler-icons/pull/1058
@naughton @CHE1RON is this issue fixed in the newest versions of
@tabler/icons-react?I was using Tabler Icon this way in 2.4.7…
Now i’m using it this way in 3.1.0…
This is allowing us to create icon components and use them in multiple areas while only have a single Icon declared. We can also override the icon props as required for specific use cases.
From version 3, the implementation outside of the library is a lot more complex and seems unnecessary. I do agree with the comments in this thread. However, I don’t think the type suggested quite fits our use case.
maybe you could export a type like this for a better “dx”?
@naughton @dandudzi those changes are non intentional, I’m working on w 3.0.1 with fixes