Return to site
· Webapplications,Web,images,React JS
broken image

To load a local image to the react program you have two ways to do that. First one is to use imports.

// ...later

All the assets are handled by the build system and this will get filenames with hashes in production build so this method is good. The drawback is that if the file is moved to another location or deleted you will get an error. Second method is to use the public folder.

 Its not a best way. If you have a huge quantity of images and importing all of them one by one is a cumbersome job so you can use this method. Cons of this method is that you have to watch for cache bursting and be careful about the moved or deleted files and check them by yourself.Read more