I'm trying to use this set of icons here in my dynamic table component. My current hack was to drag the entire folder from npm_modules into my current directory... this probably isn't good practice, is there a better way to approach this?
but I've got so far, now I'm stuck with this error:
Unhandled Rejection (Error): Cannot find module './cro.png'
> 104 | src={require('./cryptocurrency-icons/32/color/'+ (coin.symbol ? coin.symbol : "generic") + '.png')}
It's because there might not be an icon for a few of the assets in my table. If that's the case, I'm trying to use the generic icon instead.
if ((typeof datalol !== "undefined")
&& datalol !== null) {
const coins = datalol.getCoins.assets;
for(let i = 0, l = coins.length; i < l; i++) {
var rows = coins.map((coin: any) => ({
cells: [
{
key: 'icon',
content: (
<span style={{ display: 'flex', alignItems: 'center' }}>
<div style={{ marginRight: 8 }}>
<img
alt="icon"
style={{ width: 28, height: 28 }}
src={require('./cryptocurrency-icons/32/color/'+ (coin.symbol ? coin.symbol : "generic") + '.png')}
/>
</div>
</span>
),
},
{
key: 'name',
content: (
<span style={{ display: 'flex', alignItems: 'center' }}>
{coin.name} <p style={{fontSize: 10, paddingLeft: 5}}>[{coin.symbol.toUpperCase()}]</p>
</span>
),
},
],
}))
}
}
How close am I?
When I do:
src={require('./cryptocurrency-icons/32/color/'+ (!coin.symbol ? coin.symbol : "generic") + '.png')}
It shows the generic icon for them all.
Cannot find module './cro.png'. Require is definately looking for cro.png (becausecoin.symbol === true) which can't be found as its not there