Closed juanparadox closed 7 years ago
Hey, I'm sorry but I don't have any experience with React, so I won't be able to solve your issue. However I'll leave it here so somebody else can help you out.
If you find a solution to your problem, please post it here so even others can benefit from it.
You can just use webpack and require
for that:
{
test: /\.svg$/,
use: [
{
loader: 'file-loader'
}
]
},
const svg = require(`cryptocoins-icons/SVG/${dynamicCoinCode.toUpperCase()}.svg`);
const altSvg = require(`cryptocoins-icons/SVG/${dynamicCoinCode.toUpperCase()}-alt.svg`);
Is there an easier way to be able to use these SVG files in React since relative URL strings do not work great when rendering a React component?
Importing ALL of the SVG files one by one seems like overkill and there may be cases where not all are needed.