How to import many Pictures from a network drive?

I am working on a project where I have to dynamically import many pictures from a network drive.

First I tried it with the require option but it threw me an error. I also tried it with a dynamic import inside a useEffect like this:

const [image, setImage] = useState("");

useEffect(() => {
import(`N:\filepath${imagename}`).then((img) => setImage(img.default));`
}, []);

Now the pictures are getting imported but the project compiles very slowly and also i get the error Error from chokidar (N:filepath): Error: UNKNOWN: unknown error, watch inside the VS Code console. The error stops after about 30 seconds and then the project compiles without any problem.

Is there a better way without errors to do it?

Answer

I fixed it. The problem wasn’t my code it was the CRA Chokidar config. I solved it by setting the variable CHOKIDAR_USEPOLLING=true inside the .env file.