aykutkardas / react-icomoon

It makes it very simple to use SVG icons in your React and React-Native projects.
https://svgps.app
MIT License
216 stars 22 forks source link

How to set iconSet programmatically #41

Closed EmreDereli closed 1 year ago

EmreDereli commented 1 year ago

Thanks for this awesome package!! I have a different folder structure and I want to set iconSet programmatically. Is there a way to do it?

aykutkardas commented 1 year ago

You can set the iconSet at the component define stage according to a certain situation. Or it is possible to add a different iconSet while you are going to show the Icon.

import IcoMoon from "react-icomoon";

import iconSet from "./selection.json";
import otherIconSet from "./other-selection.json";

const Icon = ({ other, ...props }) => (
  <IcoMoon iconSet={other ? otherIconSet :  iconSet} {...props} />
);

export default Icon;

or

 <Icon iconSet={otherIconSet} name="camera" size={20} />

Examples and methods can be multiplied. This package offers unlimited freedom in this regard.