I have the following structure in my project folder:
src
|
-> assets
|
-> general-icons
|
pointer-arrow.svg
|
-> components
|
-> lazy-loader
|
LazyLoader.tsx
LazyLoader is a functional react component in which i dynamically import a component, in this case, a svg file
import React from 'react';
export default function LazyLoader(path: string) {
return React.lazy(() => import(path));
}
The 'path' propert is a string that contains the relative path to the svg file:
src/assets/general-icons/pointer-arrow.svg
And the pointer.svg is a normal svg:
<svg version="1.1" width="24" height="24" viewBox="0 0 24 24">
<path d="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z" />
</svg>
When i call the LazyLoader component passing the path as parameter, it gives an error as it couldn`t find the svg module:
Error: Cannot find module 'src/assets/general-icons/pointer-arrow.svg'
Anyone has any thoughts what´s going on?