Can i import the SVG file as a react component with dynamic import() Expressions?
From this answer from stackoverflow, I got a solution on how to import svg as ReactComponent and change their color/width, etc.
But is it possible to do the same for dynamic import? My functional component:
import * as React from 'react';
import SvgIconComponent from './SvgIcon.Interface';
import {ReactComponent} from '*.svg';
const SvgIcon: React.FC =({width, color, name}) =>
{
import(`../../assets/icons/${name}.svg`).then((Icon) => {
return
});
};
export default SvgIcon;
In the current implementation I get errors:
TS2749: 'ReactComponent' refers to a value, but is being used as a type here. // .then((Icon as ReactComponent)
TS2604: JSX element type 'Icon' does not have any construct or call signatures. // .then(Icon)