muffinresearch/payment-icons

How to use in something like react?

tbaustin opened this issue · 3 comments

I tried doing import payment from 'payment-icons' and get Cannot find module 'payment-icons'. How does this work?

@tbaustin You'll need to use the svg like you do any other image asset. Exactly how will depend on what you're using in your build process.

If you're using webpack for example, then as long as your loader config understands svg you can import like you would with any other image. Here's an example for doing that (this is from create-react-app which uses webpack)

Doing it that way you'll need to find the path from node_modules/payment-icons/ so if you're looking for the flat visa icon that should be something like this:

import visa from 'payment-icons/min/flat/visa.svg';

@tbaustin you can also make a sprite with yarn run sprite and then move it to your project folder (or copy css and sprite image from the demo page).

The README has now been updated with the info from this issue.