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

Icon is not displaying. href is #undefined #462

Open
muni2explore opened this issue Apr 26, 2023 · 6 comments
Open

Icon is not displaying. href is #undefined #462

muni2explore opened this issue Apr 26, 2023 · 6 comments

Comments

@muni2explore
Copy link

/* eslint-disable react/jsx-key */
import { Icon } from "@netdata/netdata-ui";

function App() {

  return (
    <>
      <div>
        <Icon name="gear" size="large" />
      </div>
    </>
  )
}

export default App
# node - v18.12.0
{
"dependencies": {
    "@netdata/netdata-ui": "^2.15.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "styled-components": "^5.3.10"
  },
 }

Screenshot 2023-04-26 at 6 07 37 PM

@muni2explore
Copy link
Author

I think this screenshot will help you, to quickly debug the issue.

Screenshot 2023-04-27 at 5 41 22 PM
Screenshot 2023-04-27 at 5 41 37 PM

@muni2explore
Copy link
Author

muni2explore commented Apr 27, 2023

There is no id property in iconSymbol instance. It always throwing `

undefined`.

None of the icon are displaying.

I think it might issue with 'path' to the SVG files. All files location are starting like this /node_modules/@netdata/netdata-ui/lib/components/icon/assets/gear.svg

@muni2explore
Copy link
Author

Becuase of this issue Icon used in all the components are not working. please check and let me know

@novykh
Copy link
Collaborator

novykh commented Apr 27, 2023

You need to use svg-sprite-loader if you are using webpack for the svg of @netdata/netdata-ui, otherwise some other tool appropriate based on your build needs.

@muni2explore
Copy link
Author

I am using Vite for build. Can you please suggest me appropriate plugins?

@muni2explore
Copy link
Author

muni2explore commented May 12, 2023

import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react';
import svgLoader from 'vite-svg-loader';
import * as path from 'path';

// https://vitejs.dev/config/
export default ({ mode }) => {
  // eslint-disable-next-line prettier/prettier
  process.env = {
    ...process.env,
    ...loadEnv(mode, path.resolve(__dirname, 'src', 'environments')),
  };

  return defineConfig({
    plugins: [
      react(),
      svgLoader({
        defaultImport: 'raw',
      }),
    ],
  });
};

I am using above vite configuration. But still none of SVG icons showing.

Please help me to solve this issue. @novykh

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