unplugin-icons icon indicating copy to clipboard operation
unplugin-icons copied to clipboard

Default class is not merged when using react

Open santiagocezar opened this issue 3 years ago • 0 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,
  // ...
});

santiagocezar avatar Jan 21 '22 18:01 santiagocezar