最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

reactjs - Tabler icons for React slowing down app on initial load - Stack Overflow

matteradmin6PV0评论

Given a new React app using Vite with no content yet ( .tsx )

When I'm using Tabler Icons for React ( ) and change the content of main.tsx to this ( .tsx )

import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import { IconArrowLeft } from '@tabler/icons-react';

createRoot(document.getElementById('root')!).render(
  <StrictMode>
    <div>
      <div>See icon below</div>
      <IconArrowLeft />
    </div>
  </StrictMode>
);

I get huge performance issues. The initial load time is increased and whenever I'm refreshing the page it takes a lot of time. Did I miss something in the docs I should setup before using the icons?

I see a lot of network requests for tabler, it seems the library is fetching some chunks first.

Given a new React app using Vite with no content yet ( https://stackblitz/edit/vitejs-vite-7xucud?file=src%2Fmain.tsx )

When I'm using Tabler Icons for React ( https://tabler.io/docs/icons/react ) and change the content of main.tsx to this ( https://stackblitz/edit/vitejs-vite-sszcqw?file=src%2Fmain.tsx )

import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import { IconArrowLeft } from '@tabler/icons-react';

createRoot(document.getElementById('root')!).render(
  <StrictMode>
    <div>
      <div>See icon below</div>
      <IconArrowLeft />
    </div>
  </StrictMode>
);

I get huge performance issues. The initial load time is increased and whenever I'm refreshing the page it takes a lot of time. Did I miss something in the docs I should setup before using the icons?

I see a lot of network requests for tabler, it seems the library is fetching some chunks first.

Share Improve this question edited Nov 16, 2024 at 10:46 baitendbidz asked Nov 16, 2024 at 10:43 baitendbidzbaitendbidz 8054 gold badges22 silver badges71 bronze badges 4
  • You can try import 'import IconArrowLeft from '@tabler/icons-react/IconArrowLeft'; – antokhio Commented Nov 16, 2024 at 10:45
  • That didn't work, the file doesn't exist. Also tried iconArrowLeft, icon-arrow-left and icon_arrow_left – baitendbidz Commented Nov 16, 2024 at 10:48
  • 1 same issue? github/tabler/tabler-icons/issues/1233 – cmgchess Commented Nov 16, 2024 at 10:56
  • yeah, this seems to be the issue! – baitendbidz Commented Nov 16, 2024 at 11:19
Add a comment  | 

1 Answer 1

Reset to default 12

try adding this to the vite.config.ts file:

Credit: https://github/tabler/tabler-icons/issues/1233#issuecomment-2428245119

export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      ...
      '@tabler/icons-react': '@tabler/icons-react/dist/esm/icons/index.mjs',
    },
  }
Post a comment

comment list (0)

  1. No comments so far