-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description
My tech stack that I currently use is:
Vite: 6.4.1,
Tabler/icons-react: 3.36.0
And the same issue it ocurred again.
For put some points at the road, I use firebase database services to get the icon's name. Cause that, I created a file to dynamically import only the icon that I'm going to use not all the bunch.
But honestly these doesn't occured...
Package
- @tabler/icons
- @tabler/icons-eps
- @tabler/icons-pdf
- @tabler/icons-png
- @tabler/icons-webfont
- @tabler/icons-sprite
- @tabler/icons-preact
- @tabler/icons-react
- @tabler/icons-react-native
- @tabler/icons-solid
- @tabler/icons-svelte
- @tabler/icons-svelte-runes
- @tabler/icons-vue
- Figma plugin
- source/main
- other/not relevant
Version
3.36.0
Browser
- Chrome/Chromium
- Firefox
- Safari
- Edge
- iOS Safari
- Opera
- Other/not relevant
Operating system
- Windows
- Linux
- macOS
- ChromeOS
- iOS
- Android
- Other/not relevant
Steps to reproduce
- Use the code below:
import {
forwardRef,
createElement,
lazy,
Suspense,
type ComponentType,
} from "react";
type TablerIconComponent = ComponentType<any>;
const iconCache: Record<string, TablerIconComponent> = {};
function loadIcon(name: string) {
if (!iconCache[name]) {
iconCache[name] = lazy(async () => {
const mod = await import("@tabler/icons-react");
const Icon = (mod as unknown as Record<string, TablerIconComponent>)[name];
if (!Icon) {
throw new Error(`Tabler icon "${name}" does not exist`);
}
return { default: Icon };
});
}
return iconCache[name];
}
const Icon = forwardRef(
(
{
name,
size = 24,
color = "currentColor",
strokeWidth = 2,
className = "",
...rest
}: any,
ref
) => {
if (!name) return null;
const Icon = loadIcon(name);
return (
<Suspense fallback={null}>
{createElement(Icon, {
ref,
size,
color,
strokeWidth,
className,
...rest,
})}
</Suspense>
);
}
);
Icon.displayName = "Icon";
export default Icon;
- Run the app
- Notice that network seccion all the chuncks
Checklist
- I have searched if someone has submitted a similar issue before and there weren't any. (Please make sure to also search closed issues, as this issue might already have been resolved.)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working