unplugin / unplugin-icons

🤹 Access thousands of icons as components on-demand universally.

Home Page:https://www.npmjs.com/package/unplugin-icons

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Default class is not merged when using react

santiagocezar opened this issue · comments

Similar to issue #53, but React not Vue.

Setting classNameon a icon component overrides the default class set in the config. This is because inside the declaration the className prop is set to $defaultClass, but after that props is spread and overrides className

This is how the declaration kinda looks (got it via console.logging the component)

const icOutlineShoppingCart = (props) => /* @__PURE__ */ _jsxDEV("svg", {
  style: {
    color: "red"
  },
  className: "my-default-class",
  ...props,
  // ...
});

IMO it should be something like

const icOutlineShoppingCart = ({className, style, ...props}) => /* @__PURE__ */ _jsxDEV("svg", {
  style: {
    color: "red"
    ...(style || {}) // might be undefined
  },
  className: "my-default-class" + " " + (className || ""), // could be undefined too 
  ...props,
  // ...
});